Priority Queue Processing

Company: HSBC_9sep

Difficulty: medium

Problem Statement

Priority Queue Processing Problem Description A set of N elements is inserted into a priority queue. Element i is a pair (x[i], y[i]) , where x[i] is the element's value and y[i] is its priority. The queue orders elements as follows: An element with a larger priority y comes before an element with a smaller priority. If two elements have the same priority, the element with the smaller value x comes first. The K elements at the front of the queue (the K highest-priority elements under this order) are removed. Report the elements that are not removed , in the same queue order: from the highest priority to the lowest, and in increasing order of x among equal priorities. Complete the function processQueue(n, x, y, k) , which returns the values x of the remaining elements in that order. Input Format N x[0] y[0] x[1] y[1] ... x[N-1] y[N-1] K Line 1 contains the integer N , the number of elements. Each of the next N lines contains two integers x[i] and y[i] : the value and the priority of ele