14320 - 2024_IDS_Spring_Lab9_Min_Heap   

Description

Please implement a binary min heap that supports the following operations:

- `1 x`: Insert number x
- `2`: Remove an element with smallest value in the heap.  If the heap is already empty, ignore this command.
- `3`: Report the smallest number in the heap.  If the heap is already empty, print "EMPTY" (without quotation mark).

Input

The first line contains an integer q, being the number of operations.

The following lines are the operations described in the problem statements.

Restrictions

- 1 <= q <= 2 * 106
- -109 <= x <= 109

Output

For each query with type 3, print the answer in one line.

Sample Input  Download

Sample Output  Download

Tags




Discuss