Rafting
Rafting down rivers with inflatable boats is a thrilling and enjoyable experience. In rafting, the crew consists of to paddlers who navigate the inflatable boat through rivers with difficulty levels ranging from class to class , depending on the water's velocity and the terrain of the riverbed. In Greece, dozens of rivers, including Acheron, Voidomatis, Erymanthos, and Loussios during the winter months, become winter resort destinations.
Sporting rafting involves descending the river along a specific route, passing through selected obstacles, in the shortest time possible. Each inflatable boat descends the course, passing oblingingly through the selected obstacles (valid descent), and based on its time, the finishing tables determine its position in the overall ranking. For example, the first boat will inevitably be in position . The second boat will be in position or , and the -th boat in any position from to .
Problem:
Develop a program in one of the IOI languages (Pascal, C, C++, Java) that, after reading the position that each raft holds in the overall ranking up to that moment, calculates the final position of each raft after the end of the race.
Input Files:
Input files named rafting.in are text files with the following structure: The first line contains an integer , the number of rafts participating in the race. The second line contains integers separated in pairs by a space: the positions in the overall ranking held by the respective rafts up to that point.
Output Files:
Output files named rafting.out are text files with the following structure: They have one line containing integers, as many as the rafts, separated in pairs by a space. Each number must be the ordinal number of the raft that will occupy the corresponding position in the final ranking.
Examples of Input - Output Files:
1st
STDIN (rafting.in)
10
1 2 3 4 5 6 7 8 9 10
STDOUT (rafting.out)
1 2 3 4 5 6 7 8 9 10
2nd
STDIN (rafting.in)
10
1 1 1 1 1 1 1 1 1 1
STDOUT (rafting.out)
10 9 8 7 6 5 4 3 2 1
3d
STDIN (rafting.in)
7
1 1 3 2 3 1 5
STDOUT (rafting.out)
6 2 4 5 7 1 3
Explanation: In the 1st example, each raft that finishes has a worse time than the previous ones and ranks last, while in the 2nd example, each raft has a better time than the previous ones and ranks first.
Constraints:
- For test cases worth 50%, of the total points, it will be:
1 Ν 10.000 - For test cases worth 100%, of the total points, it will be:
1 Ν 500.000
Attention! Be sure to read the input and print the output efficiently, especially if you are programming in C++ or Java.
- Formatting: In both the input and the output, each line terminates with a
newline
character. - Maximum execution time: 1 sec.
- Maximum available memory: 64 MB.
- Headers in the source code: At the beginning of your source code, you should use the following headers.
(* USER: username
LANG: PASCAL
TASK: rafting *)
for PASCAL coders
/* USER: username
LANG: C
TASK: rafting */
for C coders
/* USER: username
LANG: C++
TASK: rafting */
for C++ coders
/* USER: username
LANG: Java
TASK: rafting */
for Java coders
# USER: username
# LANG: Python
# TASK: rafting
for Python coders
Comments