I submitted the following solution for today's B during the contest: https://pastebin.com/VPrGHv3F But even later when i saw the test case, i couldn´t figure out what i did wrong, cause i think my logic is correct. Can someone explain why is my algorithm failing? Are there any corner cases in this problem?
Thanks in advance, have a great day.