PLEASE HELP ! HOW TO REDUCE THE TIME LIMIT

https://www.codechef.com/viewsolution/32290783

Your sorting is taking O(n^2). So,it is giving TLE. Use inbuilt sort function. It takes O(nlogn).

1 Like