#K56212. Assign Ranks to Participants

    ID: 30149 Type: Default 1000ms 256MiB

Assign Ranks to Participants

Assign Ranks to Participants

You are given the number of participants and their scores in non-increasing order. Your task is to assign a rank to each participant. Participants with the same score receive the same rank, which is the lowest rank in that group. Formally, let (R[i]) denote the rank of the (i^{th}) participant (1-indexed). If (score[i] = score[i-1]), then (R[i] = R[i-1]); otherwise, (R[i] = i). Note that after a tie, the ranking skips the intermediate values. For example, if the scores are [100, 100, 90, 90, 80, 75], the output ranks should be [1, 1, 3, 3, 5, 6].

inputFormat

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

outputFormat

Output a single line containing (n) space-separated integers denoting the ranks assigned to the participants.## sample

6
100 99 98 97 96 95
1 2 3 4 5 6

</p>