Wormholes task-4 (AC but need explanation)

Hello :slight_smile: , i kept getting WA on task-4 only, and I couldn’t figure out what is wrong…
but looking at my code deeply, i “thought” that the second part of the condition on line 103
bIt != w.begin() is redundant, because if only a bigger element exists, surely it won’t be the first one after sorting (since it is guaranteed that there is at least one valid wormhole pair for some contest) , so removed that part with no clue that it could lead to AC, and sure enough i got AC… :neutral_face:

doesn’t work, don’t know why… it works, don’t know why:rofl:

WHY! :laughing:

You can see the only difference between the AC solution
https://www.codechef.com/viewsolution/31997593
and the WA at task-4 solution
https://www.codechef.com/viewsolution/31996875

is at line 103

Can you help me understand why? or give me input like task-4?

Thanks :slight_smile:

1 Like

dun even know