TLE in PRMQ of june challenge

i am getting in tle in last subtask despite nlogn complexity from this


(https://www.codechef.com/viewsolution/14365117) . Can somebody help me out?