Skip to main content

Practice · 2 of 3

Sparse Inversions

CHALLENGE
Difficulty: advanced+25 XP

**Problem.** Each query: n then n values up to 1e9 (duplicates allowed). Print the number of inversions. **Constraints:** 1 ≤ n ≤ 200000; 1 ≤ a_i ≤ 10^9. Compression + Fenwick; the merge-sort W counts equal pairs.

Back to lesson: Practice: Synthesis Gauntlet