#P11296. [NOISG 2018 Prelim] Snail
[NOISG 2018 Prelim] Snail
Background
Translated from NOISG 2018 Prelim A. Snail.
Problem Description
A snail is trapped in a well of height .
The snail keeps trying to climb out of the well. Specifically, in one day the snail goes through stages. In stage , it climbs meters toward the top of the well (can be negative). When the snail’s height is greater than or equal to the height of the well opening, it leaves the well. When the snail’s height is less than , its height is considered to be .
You are asked to find the earliest time when the snail leaves the well, or report that there is no solution.
Note that both days and stages are 0-indexed, meaning the first stage is actually stage . Also, you may need to use long long to store the input numbers.
Input Format
The first line contains two integers . The next line contains integers, where the -th integer represents .
Output Format
Output one line with two integers , meaning the snail leaves the well on day at stage . If it can never leave, output -1 -1.
3 1
1
2 0
5 1
-1
-1 -1
5 2
4 -2
1 0
Hint
Sample #1 Explanation
At stage on day , it climbs meter, reaching a total height of meter.
At stage on day , it climbs meter, reaching a total height of meters.
At stage on day , it climbs meter, reaching a total height of meters, and leaves the well.
Sample #2 Explanation
Clearly, the snail can never leave.
Constraints
| Subtask | Score | Special Properties |
|---|---|---|
| Samples | ||
| All are the same | ||
| None | ||
For of the testdata: $1 \leq H \leq 10^{12}, -10^{12}\leq P_i\leq 10^{12}, 1\leq N \leq 10^4$.
Translated by ChatGPT 5