#P3378. 【模板】堆

【模板】堆

Description

Given a sequence that is initially empty, support the following three operations:

  1. Given an integer xx, insert xx into the sequence.
  2. Output the smallest number in the sequence.
  3. Delete the smallest number in the sequence (if multiple numbers are smallest, delete only 11).

Input Format

The first line contains an integer nn representing the number of operations.
Then follow nn lines, each describing one operation. Each line first contains an integer opop indicating the operation type.

  • If op=1op = 1, then an integer xx follows, meaning to insert xx into the sequence.
  • If op=2op = 2, it means to output the smallest number in the sequence.
  • If op=3op = 3, it means to delete the smallest number in the sequence. If multiple numbers are smallest, delete only 11.

Output Format

For each operation 22, output one line with one integer representing the answer.

5
1 2
1 5
2
3
2

2
5

Hint

Constraints

  • For 30%30\% of the testdata, it is guaranteed that n15n \leq 15.
  • For 70%70\% of the testdata, it is guaranteed that n104n \leq 10^4.
  • For 100%100\% of the testdata, it is guaranteed that 1n1061 \leq n \leq 10^6, 1x<2311 \leq x \lt 2^{31}, op{1,2,3}op \in \{1, 2, 3\}.

Translated by ChatGPT 5