Greedy...UVA 410 Station Balance getting WA

I have tried to solve this problem as Prateek vaia Asked in greedy tutorial. the code link is given below


but I m getting WA.I can’t figure out what’s wrong with my code,I want help to clear my doubt…ASAP