getting runtime error

please help me. my solution of problem
http://www.codechef.com/problems/FIRESC

is passing all the test cases but on codechef it is getting runtime error.
please suggest improvement

http://www.codechef.com/viewsolution/6827440