2015 Mock CCC by Alex and Timothy
Miyuki is competing in a sports event known as the Ice Pillars Break. In this event, there are
Scoring
In addition to the constraints above, the following will hold:
- For test cases worth 20% of the points,
. - For test cases worth 60% of the points,
, .
Input Specification
The first line of input will have the integer
For the next
Output Specification
Output one integer, the minimum number of seconds required to reduce the durability of all pillars to 0 or lower.
Please note that this answer may be very large and is not guaranteed to fit within a 32-bit integer.
Sample Input 1
5
5 5
7 2
8 1
2 0
1 3
Sample Output 1
14
Explanation for Sample 1
Destroy the 5th pillar, then the 1st pillar, then the 2nd pillar, and finally the 3rd pillar. At this point, the 4th pillar will already be destroyed.
Sample Input 2
3
5 6
6 4
4 0
Sample Output 2
5
Explanation for Sample 2
If you knock over the 1st pillar, you get a chain reaction which destroys all other pillars.
Comments