Problem 02A. Count Smaller Numbers After Self ≡

Author:Pavel Mesenev   Time limit:3 sec
Input file:Standard input   Memory limit:256 Mb
Output file:Standard output  

Statement

You are given an array of n integers a0, a1, …, an − 1. For every index i, compute ci = \#{ j: j > i and aj < ai }, the number of elements to the right of position i that are strictly smaller than ai.

Input format

The first line contains one integer n. The second line contains n space-separated integers a0… an − 1.

Output format

Print n space-separated integers c0 c1 … cn − 1.

Constraints

1 ≤ n ≤ 2 ⋅ 105

 − 109 ≤ ai ≤ 109

Sample tests

No. Standard input Standard output
1
4
5 2 6 1
2 1 1 0
2
5
1 2 3 4 5
0 0 0 0 0
3
4
4 3 2 1
3 2 1 0

0.035s 0.009s 18