Goal Statistics

Time limit: 0.7s Memory limit: 64MB Input: Output:

Lately, Stefan has been interested in studying football statistics and one day, he discovered a new metric called "expected goals" xGxG. In order to see how can xGxG affect football games, he gathered data from various football games and now he needs your help to process the data he got.

In order to start the research, he told you that there will be qq events during the football season, and the events are of two types:

1 k1 \ k: His database gets a scoring chance worth k xGk \ xG. Since xGxG is usually represented as a real number, he gave you its value multiplied by 10610^6, so that kk is an integer. Therefore, kk can be between 11 and 10610^6, on a probability scale from 10610^{-6} to 11 (the probability can never be equal to 00).

2 p2 \ p: He wants to find the smallest amount of xGxG needed in order for a team to score pp goals, if we assume that all the scoring chances have been converted into goals.

The database became really big and Stefan got into trouble, so it's up to you to help him!

Input data

The first line of the input contains qq, the number of queries.

The next qq lines of the input contain two integers typetype and kk. For type 22, pp is guaranteed to be at most equal to the number of events of type 11 which happened already before the current query.

Output data

The output will contain on each line, the answers for the queries of type 22, in the order from the input.

Constraints and Clarifications

  • 1type21 \leq type \leq 2;
  • 1q1061 \leq q \leq 10^6;
  • 1k1061 \leq k \leq 10^6;
  • 1p1061 \leq p \leq 10^6;
  • For tests worth 3030 points, 1q21031 \leq q \leq 2 \cdot 10^3, 1k1001 \leq k \leq 100.
  • For tests worth 3030 more points, 1k1001 \leq k \leq 100.

Example 1

stdin

10
1 20
1 8
1 14
1 11
2 3
1 5
1 8
1 11
2 5
2 7

stdout

33
43
77

Explanation

After the first 55 queries, the array is 2020, 88, 1414, 1111. The smallest amount of xGxG we can get from 33 values is obtained by taking 88, 1111 and 1414 and the xGxG sum is 3333.

After the first 99 queries, the array is 2020, 88, 1414, 1111, 55, 88, 1111. The smallest amount of xGxG we can get from 55 values is obtained by taking 88, 1111, 55, 88 and 1111 and the xGxG sum is 4343.

After the first 1010 queries, the array is 2020, 88, 1414, 1111, 55, 88, 1111 and we have to take every single value, and the sum is 7777.

Log in or sign up to be able to send submissions!