#K12721. Final Queue Order Determination
Final Queue Order Determination
Final Queue Order Determination
You are given a queue of n people. Each person is described by two integers: the waiting time they have already experienced and their patience limit.
The people are initially arranged in the order of their indices (from 1 to n). A simulation process is applied where you repeatedly take the person at the front of the queue and determine if they can secure their final position. Specifically, for the person at the front with waiting time \(w\), if the queue becomes empty after removal or if \(w \leq p'\), where \(p'\) is the patience limit of the new person at the front, then the removed person is confirmed at that position in the final order. Otherwise, if \(w > p'\), the person is moved to the back of the queue.
Your task is to simulate this process and output the final order (as 1-indexed positions) in which the people finalize their positions.
inputFormat
The input is read from stdin and consists of:
- An integer \(n\) representing the number of people.
- \(n\) lines each containing two integers: the waiting time \(w\) and the patience limit \(p\) of each person.
outputFormat
The output should be written to stdout as a single line containing the final order of the people (their 1-indexed positions), separated by a space.
## sample5
2 3
0 4
1 2
3 5
2 1
2 3 5 1 4