Rightward Comparison

In a land filled with arrays and numbers, an intriguing challenge awaits you. Your task is to process an array and, for each element, calculate the count of strictly larger numbers that appear to the right of that element.
Formally, given an array of n integers, for each element , you need to calculate the count of elements , such that j > i and .
Will you showcase your coding prowess and masterfully solve this captivating problem?


The first line contains a single integer n (1 ≀ n ≀ 100 000), representing the size of the array.
The second line contains n space-separated integers representing the elements of the array ().


Print n space-separated integers, where the -th integer represents the count of strictly larger numbers to the right of .


5 3 1 4 2 5
2 3 1 1 0
4 1 2 3 4
3 2 1 0


Time limit: 4 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue