QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 512 MB Puntuación total: 100

#2613. EIP1559

Estadísticas

你是一位热衷于以太坊的研究人员。最近,以太坊通过了一项决议,将交易的 gas 费率从一个值 $gasPrice$ 更改为一对值 $(maxFee, maxPriorityFee)$。交易的精确 gas 价格计算公式为 $gasPrice = \min(maxFee, maxPriorityFee + baseFee)$,其中 $baseFee$ 是一个随时间变化的参数。

你需要维护一个动态的交易集合。在某些时刻,你需要查询对于给定的 $baseFee$,集合中交易的最大 $gasPrice$ 是多少。

具体来说,你需要维护一个支持以下三种操作的交易集合:

  1. 向集合中添加一个 gas 费率为 $(maxFee, maxPriorityFee)$ 的交易。
  2. 从集合中移除一个 gas 费率为 $(maxFee, maxPriorityFee)$ 的交易。保证集合中至少存在一个满足条件的交易。
  3. 对于给定的 $baseFee$,求出当当前基础费用为 $baseFee$ 时,集合中交易的最大 $gasPrice$。保证集合中至少存在一个交易。

输入格式

第一行包含一个整数 $t$ ($0 \le t \le 10^6$),表示操作的数量。接下来的 $t$ 行,每行的第一个整数 $type$ 表示当前操作的类型。

如果 $type = 1$,接下来的两个整数为 $maxFee$ 和 $maxPriorityFee$。你需要向集合中添加一个 gas 费率为 $(maxFee, maxPriorityFee)$ 的交易。

如果 $type = 2$,接下来的两个整数为 $maxFee$ 和 $maxPriorityFee$。你需要从集合中移除一个 gas 费率为 $(maxFee, maxPriorityFee)$ 的交易。

如果 $type = 3$,接下来的一个整数为 $baseFee$。你需要输出当当前基础费用为 $baseFee$ 时,集合中交易的最大 $gasPrice$。

保证所有 $maxFee$、$maxPriorityFee$ 和 $baseFee$ 的值均为 $[0, 10^6]$ 范围内的整数。

输出格式

对于每个 $type = 3$ 的操作,输出一行,包含一个整数,表示当当前基础费用为 $baseFee$ 时,集合中最大的 $gasPrice$。

样例

输入 1

9
1 200000 20000
1 150000 40000
1 120000 50000
1 130000 30000
3 80000
3 100000
3 140000
2 150000 40000
3 100000

输出 1

120000
140000
160000
130000

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.