Talking about this question:

Here’s the solution: https://www.codechef.com/viewsolution/13078327

I checked the editorial, and there’s not even a mention of this approach in the post or in the comments.

This makes me think that there’s something really wrong with the approach, but I can’t seem to figure out what.

If someone could point that out to me, or give me a problem test case, that’d be nice.

~Thanks.