#K34932. Rank the Cities Based on Their Scores
Rank the Cities Based on Their Scores
Rank the Cities Based on Their Scores
You are given the scores of n cities. Your task is to rank the cities based on their scores. The city with the highest score is assigned rank 1, the second highest score is assigned rank 2, and so on.
Formally, if we denote the score of a city by s, then its rank is defined as \[ \mathrm{rank}(s) = 1 + \text{index of }s\text{ in the sorted list in descending order} \]
You need to process the input from stdin
and print the resulting ranks in order corresponding to the original order of the scores.
inputFormat
The input consists of two lines:
- An integer
n
representing the number of cities. - A line containing
n
space-separated integers, where each integer represents the score of a city.
outputFormat
Output a single line with n
space-separated integers representing the rank of each city in the order they appear in the input.
3
10 50 20
3 1 2