#P1867. 【Mc生存】经验值

【Mc生存】经验值

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 nn operations. Each operation costs xx 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 xx can be negative, meaning he restores x-x HP, but HP is capped at 10). Each operation grants aa experience points (cannot be negative). In the end, he will be at level mm with tt experience.

P.S. About levels:

  • The initial level is 00. Every additional 2m2^m (where mm is the current level) experience points increases the level by 1.
  • Example 1: If clearman gains a total of 1515 experience points, then he should be level 44 with 00 experience left (151248=015 - 1 - 2 - 4 - 8 = 0).
  • Example 2: If clearman gains a total of 3939 experience points, then he should be level 55 with 88 experience left (39124816=839 - 1 - 2 - 4 - 8 - 16 = 8).

Description

Input Format

The first line contains a positive integer nn, the number of operations.

The next nn lines each contain two integers xx and aa, representing one operation of clearman.

Output Format

Output one line with two integers: the final level mm and the remaining experience tt toward the next level, separated by a space.

2
5.5 15
4.5 24

4 0

Hint

The testdata is very weak and can be solved by hand, but it is tricky.

Constraints
For 100%100\% of the testdata, 1n201 \le n \le 20.

Translated by ChatGPT 5