#C742. Ranking Participants Based on Scores

    ID: 51289 Type: Default 1000ms 256MiB

Ranking Participants Based on Scores

Ranking Participants Based on Scores

In this problem, you are given a list of scores of participants. Your task is to determine the ranking for each participant based on their score. The highest score is assigned a rank of 1. If two or more participants have the same score, they receive the same rank, and the next rank is determined by the position in the sorted order. Formally, suppose the sorted scores (in non‐increasing order) are (s_1, s_2, \dots, s_n). The ranking (r_i) is defined as follows: [ r_1 = 1, \quad r_i = \begin{cases} r_{i-1} & \text{if } s_i = s_{i-1} \ i & \text{if } s_i < s_{i-1} \end{cases} ] The output should list the ranks corresponding to the original order of input scores.

inputFormat

The first line of input contains a single integer (n) representing the number of participants. The second line contains (n) space-separated integers representing the scores of the participants.

outputFormat

Output a single line with (n) space-separated integers representing the rank of each participant in the order they were given in the input.## sample

5
100 90 90 85 80
1 2 2 4 5