Rank Transform
Replace each value by its rank: the smallest distinct value becomes 1, the next 2, and so on (equal values share a rank).
Input: the first line has N; the second line has N integers.
Output: the N ranks in the original order.
Constraints:
- 1 ≤ N ≤ 105
- −109 ≤ ai ≤ 109
Sample Tests
Input 1
5 40 10 20 20 30
Output 1
4 1 2 2 3
Input 2
1 -5
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.