Fishing
Time limit1sMemory limit1024 MB
Find the starting day among the first N days whose window of k consecutive days contains the most rainy days, choosing the smallest index on a tie.
- Level
Easy3 of 10
- Topics
- Sliding window, Array, Prefix sum
- Solved
- No attempts yet
Problem
Martynas is planning a fishing trip and wants to spend days fishing. Since fish bite best on rainy days, he wants to choose consecutive days that contain as many rainy days as possible.
Input
The first line contains two integers and : is the number of days on which the trip may start, and is how many consecutive days the trip lasts.
The second line gives the weather forecast for days as a string of characters ():
L— day is rainy;S— day is sunny.
Output
Output a single number — the day on which the trip begins. Martynas wants to leave as early as possible, so if several starting days give the maximum number of rainy days, output the smallest one. (The answer is between and .)
Constraints
- .