All I did was sorting

How did I get TLE, I used inbuilt sort (NlogN) for N <= 1e5.

Link to code : https://ide.codingblocks.com/s/213824