#P6520. [CEOI 2010] mp3player (day2)
[CEOI 2010] mp3player (day2)
Description
There is an MP3 player. If there is no operation for consecutive seconds, it will automatically go to sleep. During sleep, any key press will not perform its own function, but will only wake the player up (i.e., end the sleep).
For example, suppose and the player is currently locked. Then perform the following 4 steps:
- Press
A, wait for seconds. - Press
B, wait for seconds. - Press
C, wait for seconds. - Press
D.
After these operations, the only keys that actually take effect are B and C. Note that the player has already gone to sleep between pressing C and pressing D.
This MP3 player also has two volume control keys + and -, which increase the volume by 1 unit or decrease it by 1 unit, respectively. The volume can only be an integer between and . That is, if the volume is and you press -, or if the volume is and you press +, the volume does not change.
At first, you do not know the value of , and you want to determine it through an experiment.
The player is sleeping at the beginning. You will start from some volume , and after operations you obtain volume . The exact operations are given. Each operation is of the form +/- , meaning that you press + or - at time seconds after the experiment starts.
Unfortunately, you also do not know the value of . Now, you need to find the maximum possible value of that is consistent with the experiment, and output the corresponding .
Input Format
The first line contains three integers .
The next lines each contain a character and an integer (separated by a space). is + or -, meaning increasing or decreasing the volume.
means that the operation is performed seconds after the experiment starts. It is guaranteed that is strictly increasing in the input.
Output Format
Output one line with two integers, the values of and .
If there are multiple possible solutions, output the one with the largest . If there are still multiple solutions when is maximal, output the one with the largest .
If can be arbitrarily large, output infinity.
Please note that there is always at least one solution. Because the solution always exists. In this case, none of the key presses can take effect, so .
6 4 3
- 0
+ 8
+ 9
+ 13
- 19
- 24
5 4
3 10 10
+ 1
+ 2
+ 47
infinity
Hint
Sample Explanation
Sample 1 Explanation
When , the keys behave as: unlock, unlock, +, +, unlock, -.
At this time, for , we can obtain . But you should output the largest .
When , the last two key presses will both work normally, i.e., the volume is decreased twice in a row. Then the result cannot be , so .
Sample 2 Explanation
When , any can satisfy the condition.
Constraints
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that , , , , .
Notes
This problem is translated from CEOI 2010 day 2 T1 mp3player.
The translation copyright belongs to the problem provider
Translated by ChatGPT 5
京公网安备 11011102002149号