Student Lineup
InterviewTime limit1sMemory limit128 MB
Simulate inserting students one by one into a line, each moving forward from the end by a given number of positions, then output the final order.
- Level
Easy3 of 10
- Topics
- Simulation, Array
- Solved
- No attempts yet
Problem
At lunchtime, students draw numbers in the order in which they first stood in line.
Call the first student student 1, the second student student 2, and so on up to student N. The i-th student draws one number that is at least 0 and less than i. Starting from the end of the current line, that student moves forward by exactly the drawn number of positions and stands there.
After every student has drawn a number and moved in order, write a program that prints the final order of the students.
Input
The first line contains the number of students N. N is at most 100.
The second line contains N integers separated by spaces, in the order the students first stood in line. The number drawn by the i-th student is at least 0 and less than i.
Output
Number the students from 1 to N in their initial order. Print the student numbers in the final line order on one line, separated by spaces.