Getting TLE . Hints : for Solving the problem without brute force method !
tried merge sort?
counting inversions
look here