
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
We need a data structure that counts the number of integers greater than a given value <code>x</code> and supports insertion.
Use Segment Tree or Binary Indexed Tree by compressing the numbers to the range <code>[1,n]</code>.