Why Time Limit Exceeded?

Problem code: SPREAD (SPREAD Problem - CodeChef)
I don’t know why my code (CodeChef: Practical coding for everyone) is showing Time Limit Exceeded. I have used binary indexed tree in my code as suggested in the official solution. Would anyone like to help me to find the reason out behind the “Time Limit Exceeded” ?