FEMA2 - Editorial

I watched the editorial [- YouTube] and I tried to implement the method. My code is similar to the code shown in the editorial. But I am getting WA in the second subtask. Can anyone please tell me what is wrong with my solution CodeChef: Practical coding for everyone