TLE in Nuclear Reactors

http://www.codechef.com/viewsolution/5369640 I am getting TLE for the big cases. Just by 0.01 second. Can I optimise the solution or would I need a new approach to solve this question.

To understand TLE, please read both - FAQ answer and/or my answer.