getting wrong answer in CISTFILL spoj

i am constantly getting wrong ans in SPOJ.com - Problem CISTFILL
please help me out…

MY CODE
link text