Tired Terry
InterviewTime limit1sMemory limit512 MB
Given a circular sleep pattern of length n, count for how many seconds i the preceding p seconds contain fewer than d seconds of sleep.
- Level
Medium4 of 10
- Topics
- Sliding window, Prefix sum, Array, Implementation
- Solved
- No attempts yet
Problem
Terry is feeling tired and he suspects it is because of a lack of sleep. He created a device that records his sleeping pattern over a period of time measured in seconds.
Assuming that the recorded sleeping pattern keeps repeating, help Terry by letting him know how often he is tired during each of the repeating time periods.
More precisely, for integers and , we say that Terry is tired at second if from second to second (inclusive) he has slept for less than seconds.
Input
The first line of input contains three integers (), the length of Terry's sleep pattern, (), and () as described above.
The second line of input contains a single string of length which describes the period of time that is recorded. The th such character is a W if Terry is awake at the th second, or is a Z if Terry is asleep at the th second.
Output
Display a single integer which represents the number of seconds that Terry is tired during each of the repeating time periods.