Ash and Obstacles
Practice
3.5 (2 votes)
Implementation
Sorting
Easy
Easy
Problem
82% Success 682 Attempts 20 Points 1.5s Time Limit 256MB Memory 1024 KB Max Code

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

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
245 votes
Tags:
Easy
Points:20
93 votes
Tags:
Inversion CountSortingAlgorithmsAdvanced Sorting
Points:20
1 votes
Tags:
AlgorithmsEasySorting