Ash and Obstacles

3.5

2 votes
Implementation, Sorting, Easy, Easy
Problem

Ash dreams to become the Pokemon Master and he has prepared a training program common for all his Pokemons where they have to destroy obstacles.

In total, he has N Pokemons, and before the start, every one of them has some positive integer denoting the number of Obstacles destroyed. Pokemons are indexed from 1 to N. Let's denote the No. of Obstacles destroyed by his i-th Pokemon as A[i].

After the training ends, every Pokemon will end up with some positive integer position. Ash expects that his Pokemons will take places according to the no of obstacles destroyed.

He thinks that each student will take place equal to

1+Number of students with No. of Obstacles destroyed higher than his/her.

In particular, if Pokemon A has destroyed obstacles strictly lower then Pokemon B, A will get the strictly better position than B, and if two Pokemons have destroyed equal no of obstacles, they will share the same position.

Ash would like you to reconstruct the results by following his expectations.As he had to do this task daily he is really tired today, and he is asking for your help.

INPUT:

T will denote the number of total days

The first line contains integer N number of Ash's Pokemon.

The second line contains n numbers A1, A2, ... An where A[i]is the number of obstacles destroyed by the i-th Pokemon (1 ≤ i ≤ N).

Output:

In a single line, print the position after the end of the contest for each of N Pokemon in the same order as they appear in the input. Changing line after every test case.

CONSTRAINTS:

1<=T<=10

1<=N<=10^5

1<=A[i]<=10^18

Time Limit: 1.5
Memory Limit: 256
Source Limit:
Explanation

In the first case, Pokemon 2 and 3 are positioned first (there is no other Pokemon with higher rating), and Pokemon 1 is positioned third since there are two students with higher rating.

In the second case, first Pokemon is the only one on the contest.

In the third case, Pokemon 2 and 5 share the first position with highest rating, Pokemon 4 is next with third position, and Pokemons 1 and 3 are the last sharing fourth position.

Editor Image

?