9220 - Problem E (I)   

Description

Please maintain a min-max heap, which stores integers and is able to support following operations:
(1) PUSH k
- Insert an integer k into the heap. k will fit in a 32-bit signed integer.
(2) POPMIN - Delete the minimum element from the heap.
(3) POPMAX - Delete the maximum element from the heap.
(4) MIN - Print the minimum element in the heap.
(5) MAX - Print the maximum element in the heap.


Input

There is only one set of commands. Each command occupies a line, and the total number of commands is less than or equal to 5*106. You may assume that the number of elements stored in the heap will be no more than 3*106 at any time.
Case 1: For each operations O( n ), operation num:104
Case 2: For each operations O( log(n) ), operation num:106
Case 3: For each operations O( log(n) ), operation num:2*106
Case 4: For each operations O( log(n) ), operation num:5*106

 

Output

(1) POPMIN - In case that the heap is empty, print ”Error” instead.
(2) POPMAX - In case that the heap is empty, print ”Error” instead.
(3) MIN - Print the minimum element in the heap. In case that the heap is empty, print ”Null” instead..
(4) MAX - Print the maximum element in the heap. In case that the heap is empty, print ”Null” instead.

Sample Input  Download

Sample Output  Download

Tags




Discuss