TLE in Worms(CODEFORCES)

https://codeforces.com/contest/474/submission/71275516
The solution gets a TLE verdict even though the editorial says to use binary search
therefore getting a overall time complexity of O(n+m*logn).Can someone please view my code and check what’s wrong.

That doesn’t look like a binary search: you’re only reducing high/ increasing low by 1 rather than setting then to mid.

thanks for pointing out its now accepted :slightly_smiling_face:

1 Like