K-inversions URAL - 1523 (DP+树状数组)

NoSuchKey