Getting TLE in CHEFPSA (Chefina and Prefix Suffix Sums )

Can someone tell me why i am getting TLE in my solution.
Link to the problem https://www.codechef.com/problems/CHEFPSA

Link to my code
https://www.codechef.com/viewsolution/29144877

What i can infer from your code that you have used a lot of if else statements and lot of in statements which is increasing the complexity of your program. Your logic may pass for c++14, i have solved this problem in python too. I am attaching my code, see if you can improve the efficiency of your code. My Solution.

It is partially commented. If you have any queries just comment, will reply soon. Have a good day! :blush::blush:

1 Like