Lost Lineup
InterviewTime limit1sMemory limit512 MB
Given each of Jimmy's friends' distance (number of people between them and Jimmy) from the front, reconstruct the original lineup with Jimmy first.
- Level
Easy3 of 10
- Topics
- Array, Sorting, Implementation, Brute force
- Solved
- No attempts yet
Problem
Jimmy and his friends were standing in a lineup for ice cream when a huge gust blew them all around. The friends want to keep things fair and make sure everyone gets their ice cream in the order they started with. The friends do not remember the order, but each of them remembers exactly how many people were between them and Jimmy. Jimmy is always the first person in line. Can you help him and his friends remember the order?
Input
The first line contains a single integer (), the number of people in the line.
The second line contains space separated integers, where () is the number of people between the th person and Jimmy.
Jimmy is always first in the lineup.
Output
Print a single line with integers, the people in the order of the original lineup. It is guaranteed that there is always a unique solution.