Problem C
Lazy River Defense
While Tom was relaxing in the lazy river, his friend came up with a scheme to annoy him. They bought a bunch of water balloons and position themselves around the lazy river, waiting for Tom to come inside their throwing range to give him a water balloon to the face.
Everyone shares a stockpile of balloons, so after every
throw, they take
There is no travel time for the balloons, so the time between a balloon being thrown and it hitting Tom is instant.
The lazy river has
The prank ends the moment the stockpile of balloons runs out, putting an end to Tom’s misery. Please help Tom calculate how long the prank will last.
Input
First line of input contains an integer
For the next
Then, the next line contains two integers, the number of
friends joining in the prank
For the last
Output
Output how long the prank last. Your answers must have an
absolute error or relative error of at most
Sample Input 1 | Sample Output 1 |
---|---|
4 0 0 2 0 2 2 0 2 1 3 0 0 1 2 |
9 |
Sample Input 2 | Sample Output 2 |
---|---|
4 0 0 4 0 4 4 0 4 1 2 2 0 1 1 |
2 |
Sample Input 3 | Sample Output 3 |
---|---|
4 0 0 1 0 1 1 0 1 1 1 5 5 1 1 |
safe |
Sample Input 4 | Sample Output 4 |
---|---|
4 0 0 2 0 2 2 0 2 2 5 0 0 1 2 2 2 1 2 |
9 |
Sample Input 5 | Sample Output 5 |
---|---|
4 0 0 2 0 2 2 0 2 1 4 1 1 2 2 |
6 |