P1867 【MC Survival】Experience Points
Background
Seventh-grade benefit, round 2.
Description
It is said that clearman opened a Xiangyi cattle ranch in the MC world, using lava, TNT, and other brutal methods to torment cows, farming beef, milk, and experience. He wants to know what level he ultimately reaches.
He performs a total of $n$ operations. Each operation costs $x$ HP (initial HP is 10; calculate the HP cost first—if HP becomes less than or equal to 0, he dies, and this operation and all subsequent operations are invalid. Note: the HP cost $x$ can be negative, meaning he restores $-x$ HP, but HP is capped at 10). Each operation grants $a$ experience points (cannot be negative). In the end, he will be at level $m$ with $t$ experience.
P.S. About levels:
- The initial level is $0$. Every additional $2^m$ (where $m$ is the current level) experience points increases the level by 1.
- Example 1: If clearman gains a total of $15$ experience points, then he should be level $4$ with $0$ experience left ($15 - 1 - 2 - 4 - 8 = 0$).
- Example 2: If clearman gains a total of $39$ experience points, then he should be level $5$ with $8$ experience left ($39 - 1 - 2 - 4 - 8 - 16 = 8$).
# Description
Input Format
The first line contains a positive integer $n$, the number of operations.
The next $n$ lines each contain two integers $x$ and $a$, representing one operation of clearman.
Output Format
Output one line with two integers: the final level $m$ and the remaining experience $t$ toward the next level, separated by a space.
Explanation/Hint
The testdata is very weak and can be solved by hand, but it is tricky.
Constraints
For $100\%$ of the testdata, $1 \le n \le 20$.
Translated by ChatGPT 5