#P3378. 【模板】堆
【模板】堆
Description
Given a sequence that is initially empty, support the following three operations:
- Given an integer , insert into the sequence.
- Output the smallest number in the sequence.
- Delete the smallest number in the sequence (if multiple numbers are smallest, delete only ).
Input Format
The first line contains an integer representing the number of operations.
Then follow lines, each describing one operation. Each line first contains an integer indicating the operation type.
- If , then an integer follows, meaning to insert into the sequence.
- If , it means to output the smallest number in the sequence.
- If , it means to delete the smallest number in the sequence. If multiple numbers are smallest, delete only .
Output Format
For each operation , output one line with one integer representing the answer.
5
1 2
1 5
2
3
2
2
5
Hint
Constraints
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that , , .
Translated by ChatGPT 5
京公网安备 11011102002149号