Help in Codeforces 124C
Can anyone give me any hints to solve the 124C. I have not understood the editorial clearly .