Score : 100 points
Consider an infinite sequence a_1, a_2, … Initially, the values of all the terms are 0, and from this state we will sequentially perform Q operations. The i-th operation (1 ≤ i ≤ Q) is as follows:
Find the value of the largest term after these Q operations.
Input is given from Standard Input in the following format:
Q m_1 x_1 : m_Q x_Q
Print the value of the largest term after the Q operations.
3 2 10 3 -20 6 15
10
The values of each terms in the sequence a_1, a_2, … change as follows:
The value of the largest term after all the operations is 10.
3 10 -3 50 4 100 -5
1
5 56 114834 72 -149861 100 190757 192 -132693 240 133108
438699