EIP1559

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

You are an avid Ethereum researcher. Recently Ethereum passed a resolution to change the gas rate of a transaction from a value gasPrice\mathit{gasPrice} to a pair (maxFee,maxPriorityFee)(\mathit{maxFee}, \mathit{maxPriorityFee}). The exact gas price of a transaction is calculated by gasPrice=min(maxFee,maxPriorityFee+baseFee)\mathit{gasPrice}=\min(\mathit{maxFee},\mathit{maxPriorityFee}+\mathit{baseFee}), while baseFee\mathit{baseFee} is a parameter that can change over time.

You maintain a dynamic collection of transactions. At some moments, you want to know, for a specific baseFee\mathit{baseFee}, what is the largest gasPrice\mathit{gasPrice} of a transaction in the collection.

Specifically, you need to maintain a collection of transactions that supports the following three operations:

  1. Add a transaction with the gas rate (maxFee,maxPriorityFee)(\mathit{maxFee}, \mathit{maxPriorityFee}) to the collection.
  2. Remove a single transaction with the gas rate (maxFee,maxPriorityFee)(\mathit{maxFee}, \mathit{maxPriorityFee}) from the collection. It is guaranteed that there is at least one transaction that satisfies the condition.
  3. For a specific baseFee\mathit{baseFee}, find the maximum value of gasPrice\mathit{gasPrice} in the collection when the current base fee is baseFee\mathit{baseFee}. It is guaranteed that there is at least one transaction in the collection.

입력

The first line contains an integer tt (0t1060 \leq t \leq 10^6) representing the number of operations. For the following tt lines, the first integer type\mathit{type} on each line represents the type of the current operation.

If type=1\mathit{type}=1, the next two integers are maxFee\mathit{maxFee} and maxPriorityFee\mathit{maxPriorityFee}. You should add a transaction with gas rate (maxFee,maxPriorityFee)(\mathit{maxFee}, \mathit{maxPriorityFee}) to the collection.

If type=2\mathit{type}=2, the next two integers are maxFee\mathit{maxFee} and maxPriorityFee\mathit{maxPriorityFee}. You should remove a single transaction with gas rate (maxFee,maxPriorityFee)(\mathit{maxFee}, \mathit{maxPriorityFee}) from the collection.

If type=3\mathit{type}=3, the next integer is baseFee\mathit{baseFee}. You should output the maximum value of gasPrice\mathit{gasPrice} in the collection when the current base fee is baseFee\mathit{baseFee}.

It is guaranteed that all the values of maxFee\mathit{maxFee}, maxPriorityFee\mathit{maxPriorityFee}, and baseFee\mathit{baseFee} are integers in range \[0,106]\[0,10^6].

출력

For each operation with type=3\mathit{type}=3, output a line with an integer representing the current largest gasPrice\mathit{gasPrice} when the current base fee is baseFee\mathit{baseFee}.