Count Inversions

Medium · rating 1550 · Sorting

The first line has n. The second line has n integers. Print the number of inversions — pairs (i, j) with i < j and ai > aj.

Constraints: 1 ≤ n ≤ 105

Related problems

Open Count Inversions in Code Arena →