#K37622. Reward Ranking

    ID: 26018 Type: Default 1000ms 256MiB

Reward Ranking

Reward Ranking

You are given T test cases. In each test case, you are given an integer N representing the number of participants followed by N integers representing their rewards.

Your task is to compute the rank for each participant based on their reward. The ranking is defined as follows: a participant with a higher reward receives a lower rank (i.e. rank 1 is the best), and participants with equal rewards receive the same rank. Formally, the rank for a participant with reward \( x \) is \( 1 + (\text{number of unique rewards greater than } x) \). Output the ranking for each test case as a sequence of numbers corresponding to the original order.

Note: Use \( \LaTeX \) format for any formulas.

inputFormat

The first line of input contains a single integer T denoting the number of test cases. For each test case:

  • The first line contains an integer N representing the number of participants.
  • The second line contains N space-separated integers representing the rewards of the participants.

outputFormat

For each test case, output a single line containing N space-separated integers where the \( i^{th} \) integer is the rank of the \( i^{th} \) participant.

## sample
3
5
100 200 100 300 200
4
100 100 100 100
5
500 400 300 200 100
3 2 3 1 2

1 1 1 1 1 2 3 4 5

</p>