HELP NEEDED IN (https://www.codechef.com/problems/CENS20E)

https://www.codechef.com/problems/CENS20E
I was getting wrong answer in this problem can anyone please help me
solution link:https://ideone.com/8kyfVp