#ABC471D. 充电器 / Chargers
充电器 / Chargers
Problem Statement
There is a charger with an unlimited number of charging slots. At time , all slots are empty.
The maximum capacity of a battery is . While a battery is plugged into a slot, it is charged at a rate of until its charge level reaches the maximum capacity (that is, the charge level increases by for every unit of time that passes).
Process queries in order. The -th query is given in one of the following formats. Here, it is guaranteed that .
- Type (): At time , plug one battery with charge level into a slot.
- Type (): At time , unplug one battery with the highest charge level from its slot, and output that battery's charge level. If there is no battery plugged into any slot, output instead.
Constraints
- For type queries, .
- For type queries, .
- For type queries, .
- The input values are all integers.
Input
The input is given from Standard Input in the following format:
Here, represents the -th query, and is given in one of the following two formats:
or
Output
Let be the number of type queries. Output lines.
The -th line () should contain the value to be outputed for the -th type query.
7 100
1 15 60
1 25 80
2 30
1 45 0
2 60
2 70
2 80
85
100
25
-1
The seven queries are processed in the following order.
- At time , a battery with charge level is plugged in. At this point, the charger has a battery with charge level .
- At time , a battery with charge level is plugged in. At this point, the charger has batteries with charge levels .
- At time , the charger has batteries with charge levels . Of these, the battery with charge level is unplugged.
- At time , a battery with charge level is plugged in. At this point, the charger has batteries with charge levels .
- At time , the charger has batteries with charge levels . Of these, the battery with charge level is unplugged.
- At time , the charger has a battery with charge level . This battery, with charge level , is unplugged.
- At time , no battery is plugged into the charger. Thus, no battery is unplugged.
20 380736236
1 21873985 256702097
2 86369729
1 114301317 288304981
1 147244640 305840435
2 150951976
1 331581391 50335458
1 352989552 47577202
1 400130024 345362760
2 458793150
2 509082216
1 591375600 197371572
1 617022014 101276068
1 679649471 310249627
1 796351653 268586022
1 825648347 129608152
2 908069704
2 921770319
1 949684819 372272469
1 971850999 335461408
2 986253026
321197841
324955640
380736236
380736236
380736236
380736236
380736236
相关
在下列比赛中: