Please maintain a minmax-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. Do nothing if no elements in heap.
(3) POPMAX – Delete the maximum element from the heap. Do nothing if no elements in heap.
(4) MIN– Print the minimum element in the heap.
(5) MAX– Print the maximum element in the heap.
(5) CLEAR– Delete all elements in the heap.
Hint : std::multiset
There is only one set of commands. Each command occupies a line, and the total number of commands is less than or equal to 500000. You may assume that the number of elements stored in the heap will be no more than 500000 at any time.
For each “MIN/MAX” command, output a line containing the value of the element on the top of the heap. In case that the heap is empty, print ”Null” instead.