#abc212d. D - Querying Multiset
D - Querying Multiset
Score : points
问题描述
Takahashi有许多空白的球和一个袋子。最初,袋子是空的。Takahashi将执行次操作,每次操作属于以下三种类型之一。
- 类型 : 在一个空白球上写入整数,然后将其放入袋子中。
- 类型 : 对于袋子中的每个球,用该球上所写的整数加上来替换它。
- 类型 : 拿起袋子里整数最小的那个球(如果有多个这样的球,取出其中一个)。记录这个球上所写的整数并将其丢弃。
对于每个,已知第次操作的类型以及如果该操作是类型或时的值。按照顺序打印出类型操作所记录的整数。
以上为通义千问 qwen-max 翻译,仅供参考。
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.
Sample Input 1
5
1 3
1 5
3
2 2
3
Sample Output 1
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.
Sample Input 2
6
1 1000000000
2 1000000000
2 1000000000
2 1000000000
2 1000000000
3
Sample Output 2
5000000000
Note that the outputs may not fit into a -bit integer.
update @ 2024/3/10 09:27:25