A single-round tournament has n competitors, numbered 1 through n in the order they competed. Each competitor earns an integer score. The organizers need the final standings list: competitors are ranked by score in descending order, and whenever two or more competitors tie on score, the competitor with the smaller original number is ranked ahead (i.e., ties are broken by earlier original position).
Given the scores, output the competitor numbers in ranked order, from first place to last place.
Line 1: an integer n.
Line 2: n integers score_1 ... score_n, where score_i is the score earned by competitor i.
A single line with n integers separated by spaces: the competitor numbers in ranked (standings) order.
Example 1
Input
4 50 50 80 50
Expected
3 1 2 4
Explanation
Competitor 3 has the highest score (80) and ranks first. Competitors 1, 2, and 4 all tie at score 50, so they are ordered by their original numbers: 1, then 2, then 4. Final standings: 3 1 2 4.
Example 2
Input
1 100
Expected
1
Explanation
With a single competitor, the standings trivially contain only competitor 1.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →