Getting TLE in PIGBANK spoj

this is my dp implementation for PIGBANK on spoj SPOJ.com - Problem PIGBANK .
i got TLE 10 times please help thanks in advance

my solution : eztC6b - Online C++0x Compiler & Debugging Tool - Ideone.com