Trouble With Interactive Problem

I’ve had some trouble solving this interactive problem. I just do a simple binary search, to find the first index that has value lower than the one we’re searching for. Then, I move on to test out whether the even number is the answer by subtracting all the sums shifted by a power of two. It fails on every case though. I can’t come up with a counter case nor spot my error. I’ve also referred to the editorial and the idea seems to be correct. Is there a problem with the bounds? Perhaps I’m printing in wrong format? Thanks, I appreciate the help.


Bump. Somebody please help find a testcase which fails. :slight_smile: @ssjgz Sorry for tag, I thought you could help.

New submission: Solution: 48898553 | CodeChef

Never mind, I made a dumb mistake in code. I just found the error, as I needed to test only up to the second greatest power of 2, not the greatest that fits into “cur”.

Here’s an AC submission in case anybody is curious: Solution: 48898677 | CodeChef

1 Like