Someone Gets Hurt
Janis and Damien are furious with Cady, after discovering she lied about being busy just to throw a "Revenge Party". Now they're confronting her.
Cady is standing at a roundabout. Janis and Damien are in their car, directly across from her. Damien begins driving around the roundabout at a constant speed, completing 1 full loop per minute. Janis stands through the sunroof, shouting her lecture down at Cady.
Janis wants her words to hit hard. She considers a sentence to be "powerful" if she finishes saying it exactly when the car is directly across from Cady — in other words, when Damien completes a full number of loops.
Here are the rules:
- Janis reads her lecture sentence by sentence, in order.
- A sentence consists of a sequence of words ending in a period (
.
). - Once she starts a sentence, she cannot stop until it's finished.
- However, she can wait before starting a sentence, to time it just right.
- Janis speaks at a fixed rate of
words per loop.
- Damien can only drive for
loops before breaking his curfew.
Janis wants to finish her lecture with as many "powerful" sentences as possible, without breaking Damien's curfew.
Input
The first line consists of an integer
, the number of words in Janis' lecture.
The second line consists of an integer
, the number of words Janis can say in one revolution.
The third line consists of an integer
, Damien's maximum number of revolutions.
The fourth line contains Janis' entire lecture, a series of words. Sentences are separated by full stops, and there is no other punctuation. There are at most
sentences in Janis' lecture. Each word is no more than
characters long.
For example, the lecture "This is one. This is two." contains
sentences with
words each.
Output
Output the maximum number of sentences Janis can finish when she is directly across from Cady (her starting point), while completing her speech and preserving Damien's curfew.
If it's not possible for Janis to complete her speech in time, output .
Clarifications
- The only characters in Janis' speech are English letters, spaces and full stops.
Example
Input 1
25
10
3
Buddy its not pretend. You are as plastic as they come. You think your shit dont stink. You think the rest of us are dumb.
Output 1
2
Janis' lecture has words, broken into
sentences:
- "Buddy, its not pretend.":
words
- "You are as plastic as they come.":
words
- "You think your shit dont stink.":
words
- "You think the rest of us are dumb.":
words
Her speaking speed is words per minute and Damien can drive for a maximum of
loops.
The optimal way to deliver her speech is as follows:
- Sentence
(
words): Janis starts immediately. The car has now completed
loops, so this sentence is not powerful.
- Sentence
(
words): She starts immediately after the first. The car has now completed
loops, so this sentence is not powerful.
- Sentence
(
words): Janis waits until the car is
loops around, then starts. The car has now completed exactly
loops, so this sentence is powerful.
- Sentence
(
words): Janis waits until the car is
loops around, then starts. It takes
minutes. The car has completed exactly
loops, so this sentence is powerful.
Janis has finished her speech, delivering powerful sentences in
revolutions. This is the highest number possible in
revolutions.
Input 2
20
6
3
See. Thats the thing with you Plastics. You think everybody is in love with you when actually everybody hates you.
Output 2
-1
It is impossible for Janis to complete her speech in time.
Comments