CHN04 solving

This is the link to the problem - https://www.codechef.com/problems/CHN04 - and my solution to this - https://www.codechef.com/viewsolution/15025578
-Can’t get what is the problem but I keep getting WA
-Can someone help?