充电器AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)There is a charger with an unlimited number of charging slots. At time $0$, all slots are empty.
有一个充电器,拥有无限多的充电槽。在时刻 $0$,所有充电槽均为空。AI (CI翻译)
The maximum capacity of a battery is $V$. While a battery is plugged into a slot, it is charged at a rate of $1$ until its charge level reaches the maximum capacity (that is, the charge level increases by $1$ for every $1$ unit of time that passes).
电池的最大容量为 $V$。电池插入充电槽后,会以速率 $1$ 充电,直到电量达到最大容量(即经过 $1$ 单位时间,电量增加 $1$)。AI (CI翻译)
Process $Q$ queries in order. The $q$-th query is given in one of the following formats. Here, it is guaranteed that $t_1 < \dots < t_Q$.
请按顺序处理 $Q$ 个查询。第 $q$ 个查询的格式如下。保证 $t_1 < \dots < t_Q$。AI (CI翻译)
- Type
$1$($1\ t_q\ w_q$): At time$t_q$, plug one battery with charge level$w_q$into a slot. - Type
$2$($2\ t_q$): At time$t_q$, 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$-1$instead.
- 类型
$1$(1\ t_q\ w_q):在时刻$t_q$,将一块电量为$w_q$的电池插入充电槽。 - 类型
$2$(2\ t_q):在时刻$t_q$,将当前电量最高的电池从其充电槽中取出,并输出该电池的电量。如果没有电池插在任何充电槽中,则输出$-1$。
Constraints
约束条件
AI (CI翻译)$1 \leq Q \leq 3 \times 10^5$$1 \leq V \leq 10^9$- For type
$1$queries,$1 \leq t_q \leq 10^9$. - For type
$1$queries,$0 \leq w_q \leq V$. - For type
$2$queries,$1 \leq t_q \leq 10^9$. $t_1 < \dots < t_Q$- The input values are all integers.
$1 \leq Q \leq 3 \times 10^5$$1 \leq V \leq 10^9$- 对于类型
$1$的查询,$1 \leq t_q \leq 10^9$。 - 对于类型
$1$的查询,$0 \leq w_q \leq V$。 - 对于类型
$2$的查询,$1 \leq t_q \leq 10^9$。 $t_1 < \dots < t_Q$- 输入中的所有数值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
Q V
\mathrm{query}_1
\vdots
\mathrm{query}_Q
Q V
\mathrm{query}_1
\vdots
\mathrm{query}_QAI (CI翻译)
Here, $\mathrm{query}_q$ represents the $q$-th query, and is given in one of the following two formats:
其中,$\mathrm{query}_q$ 表示第 $q$ 个查询,格式为以下两种之一:AI (CI翻译)
1 t_q w_q
1 t_q w_qAI (CI翻译)
2 t_q
2 t_qAI (CI翻译)
Output
输出格式
AI (CI翻译)Let $x$ be the number of type $2$ queries. Output $x$ lines.
设类型 $2$ 的查询数量为 $x$。输出 $x$ 行。AI (CI翻译)
The $k$-th line ($1 \leq k \leq x$) should contain the value to be outputed for the $k$-th type $2$ query.
第 $k$ 行($1 \leq k \leq x$)应包含第 $k$ 个类型 $2$ 查询的输出值。AI (CI翻译)
样例
7 100
1 15 60
1 25 80
2 30
1 45 0
2 60
2 70
2 80
85
100
25
-1
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
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。