#P3378. Sequence Operations

    ID: 16635 Type: Default 1000ms 256MiB

Sequence Operations

Sequence Operations

Given an initially empty sequence, you are required to support the following three types of operations:

  1. Given an integer \(x\), insert \(x\) into the sequence.
  2. Output the smallest number currently in the sequence.
  3. Delete one occurrence of the smallest number from the sequence. (If there are multiple occurrences of the smallest number, remove only one.)

All formulas are in \(\LaTeX\) format. For example, when an operation asks to add an integer \(x\), it means that the integer \(x\) should be added to the sequence, and when asked to output the smallest number, you should output the minimum among all numbers currently in the sequence.

inputFormat

The first line contains an integer \(Q\) representing the number of operations.

Each of the following \(Q\) lines describes an operation in one of the following formats:

  • 1 x: Insert the integer \(x\) into the sequence.
  • 2: Output the smallest number in the sequence.
  • 3: Remove one occurrence of the smallest number from the sequence.

You can assume that the operations of type 2 and 3 will only be given when the sequence is non-empty.

outputFormat

For each operation of type 2, output the smallest number in the sequence on a separate line.

sample

6
1 10
1 5
2
1 3
3
2
5

5

</p>