189. Round-Robin Scheduling
An operating system shares one CPU between n processes. Each needs a
certain amount of time to finish, called its burst time.
Under round-robin scheduling, each process in turn gets the CPU for at most q units, the
time QUANTUM. If it finishes within that, it leaves. If it does not, it goes to the BACK of
the queue with its remaining time and waits for another turn.
Print the order in which the processes finish. This is a real scheduler, and the queue is the whole of it.
Constraints - `1 ≤ n ≤ 100000` - `1 ≤ q ≤ 1000000` - `1 ≤ burst time ≤ 1000000`
Input
The first line contains two integers n and q, the number of processes and the time quantum.
The second line contains n space-separated integers, the burst times of processes 1 to n, in that order.
Output
Print the process numbers in the order they finish, n integers on one line, separated by single spaces.
Processes are numbered from 1.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.