Please help me in solving this https://www.codechef.com/NOV19B/problems/SC31 question

my solution is https://ide.codingblocks.com/s/148625