INVZCNT - TLE with the O(k + nlogn) solution

Please let me know why this solution of INVZCNT results in TLE.
https://www.codechef.com/viewsolution/27603341
while this doesn’t
https://www.codechef.com/viewsolution/27603350