#P5250. 【深基17.例5】木材仓库

【深基17.例5】木材仓库

Description

In Boai City, there is a timber warehouse that can store timber of various lengths, and it is guaranteed that no two pieces of timber have the same length. As the warehouse manager, you sometimes purchase stock and sometimes ship stock, so you need to maintain the inventory. There are no more than 10510^5 operations:

  • Stock in, format 1 Length: Put a piece of timber of length LengthLength (no more than 10910^9) into the warehouse. If a piece of timber with the same length already exists, output Already Exist.
  • Stock out, format 2 Length: Take out the piece of timber with length LengthLength from the warehouse. If there is no piece with exactly that length, take out the piece in the warehouse whose length is closest to the requested length. If multiple pieces satisfy this, take out the shorter one. Output the length of the timber taken out. If the warehouse is empty, output Empty.

Input Format

The first line contains an integer mm, representing the number of operations.

The next mm lines each contain one operation, in the format described in the statement.

Output Format

For each operation, output the answer as required in the statement.

7
1 1
1 5
1 3
2 3
2 3
2 3
2 3
3
1
5
Empty

Hint

Translated by ChatGPT 5