100 atcoder#ABC212D. [ABC212D] Querying Multiset
[ABC212D] Querying Multiset
Score : points
Problem Statement
Takahashi has many balls, on which nothing is written, and one bag. Initially, the bag is empty. Takahashi will do operations, each of which is of one of the following three types.
- Type : Write an integer on a blank ball and put it in the bag.
- Type : For each ball in the bag, replace the integer written on it with that integer plus .
- Type : Pick up the ball with the smallest integer in the bag (if there are multiple such balls, pick up one of them). Record the integer written on this ball and throw it away.
For each , you are given the type of the -th operation and the value of if the operation is of Type or . Print the integers recorded in the operations of Type in order.
Constraints
- All values in input are integers.
- There is one or more such that .
- If , the bag contains at least one ball just before the -th operation.
Input
Input is given from Standard Input in the following format:
Each in the -nd through -th lines is in the following format:
The first number in each line is , representing the type of the operation. If or , it is followed by a space, and then by .
Output
For each operation with among the operations, print the recorded integer in its own line.
5
1 3
1 5
3
2 2
3
3
7
Takahashi will do the following operations.
- Write on a ball and put it in the bag.
- Write on a ball and put it in the bag.
- The bag now contains a ball with and another with . Pick up the ball with the smaller of them, or . Record and throw it away.
- The bag now contains just a ball with . Replace this integer with .
- The bag now contains just a ball with . Pick up this ball, record , and throw it away.
Therefore, we should print and , in the order they are recorded.
6
1 1000000000
2 1000000000
2 1000000000
2 1000000000
2 1000000000
3
5000000000
Note that the outputs may not fit into a -bit integer.