Please Help Me in this

Is God among us? Please help me solve this question. I can’t find my error.
My Solution:
https://www.codechef.com/viewsolution/50418731

The problem is all about finding the number of inversions in an Array. Remember that the number of inversions for an Array of size N can be as large as \cfrac{N\times(N - 1)}{2} (for strictly decreasing sequence of integers).

Long story short, use long long int.

PS: You should think of a faster approach as your approach will TLE on N\ge10^5.

2 Likes

Thank you so much. It worked. I was almost having an existential crisis until you helped. :sweat_smile: :sweat_smile:

I just wanted to do it using binary search as everyone is using merge sort or upper bound methods in vector. Trying something different
Thank you again