WA in MAXBTY March_cookoff 2020

https://www.codechef.com/viewsolution/32007134

Please Look Into My Solution and tell me my fault. I am getting WA in this question since a very long time, trying again and again but the results remain the same.
Please help me out.

could you just explain your code, i mean how are you using segment tree to solve, then maybe i can help :sweat_smile:

yes ofcourse.
i am building a segment tree with each node having 3 data segments.
first one for storing max suffix sum in range, second one for storing range sum, third one for storing max prefix sum in range.
Now Breaking the Constraints in Question
1<=l<=x
y<=r<=n

so basically i am querying the seg tree for max prefix sum in range(y,n)
then querying the seg tree for max suffix sum in range(1,x)
and then querying for sum in range(x+1,y-1)

and finally the ans will be sum of all three values that i queried