I submit this solution which its time complexity is n*k*log(n) 72309942 I got TLE on test 35
and the constrain in the problem 1077F2 - Pictures with Kittens (hard version) n <= 5000, k <= 5000
I have no idea why my solution is TLE, I think it should fit in the time, Any help ?