Skip to main content

Practice · 4 of 4

Count the Inversions

CHALLENGE
Difficulty: intermediate+25 XP

**Bài toán.** An array of n integers (up to 10^9): print the number of pairs i < j with a[i] > a[j]. Use 64-bit for the answer. **Constraints:** 1 ≤ n ≤ 200 000. Coordinate compression + BIT: O(n log n).

Back to lesson: Practice: Fenwick Variant Drills