getting wrong answer in CISTFILL spoj

i am constantly getting wrong ans in http://www.spoj.com/problems/CISTFILL/
please help me out…

MY CODE
link text

//