#K40852. Max Priority Queue Operations

    ID: 26734 Type: Default 1000ms 256MiB

Max Priority Queue Operations

Max Priority Queue Operations

This problem requires you to implement a max-priority queue that supports two types of operations:

  • 0 p: Add a task with priority \(p\).
  • 1: Remove and output the task with the highest priority.

You will be given a sequence of operations. For each removal operation, remove the task with the current maximum priority and print its value. It is guaranteed that every removal operation is valid (i.e. the queue will not be empty when a removal is requested).

inputFormat

The input is provided as follows:

The first line contains an integer (N), representing the number of operations. Each of the next (N) lines contains an operation. An operation is either:

  • 0 p, where (p) is an integer denoting the priority to be added to the queue.
  • 1, indicating that the current highest priority task should be removed and its priority output.

Read from standard input (stdin).

outputFormat

For each removal operation (operation type (1)), output the removed task's priority on a new line. Write to standard output (stdout).## sample

6
0 5
0 3
0 10
1
0 8
1
10

8

</p>