I submitted the following solution for today's B during the contest: http://mirror.codeforces.com/contest/1005/submission/40123027 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.