Doubt in a problem From Webinar

I have implemented code for the problem paying up(https://www.codechef.com/problems/MARCHA1)
but it is returning “NO” for every test case can u tell me where i’ve mistaken (Here’s my code -“https://ide.codingblocks.com/s/81103”)