There are students in a queue with ID respectively. Each student has some coins . Minimum coins required for buying a meal from the canteen is .
The above process will repeat till the queue is not empty. Find the sequence of leaving the queue of students.
The first line contains an integer , the number of test cases.
Then test cases follow
The first line of each test case contains two integers and . The second line of each test case contains integers .
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, on a separate line print integers, the ID of students according to the sequence they left the queue.
1 8 7 3 1 5 3 7 4 5 2
5 3 7 6 1 4 8 2
Login to submit
This is a simple sorting problem. One thing you can notice here that there is no difference between ...