TLE in CHEFSHIP

My solution [https://www.codechef.com/viewsolution/33344786] for CHEFSHIP gives TLE despite having same complexity as accepted solutions ,please check.

Accepted solutions are bad, you aren’t supposed to have O(n^2)

I don’t get it.
Are the test cases modified after the contest ?

Yes

Ok.
Didn’t know about this.
Thanks.

Usually, no, but in this case, yes: see e.g. here and here.

1 Like

Yes. Got it.
Thanks

1 Like