Maximum sum-SEGMENT TREE

i am getting right answers on codeblocks ide but here its showing bad alloc and on submission all answers are wrong…whats wrong in below implementation:

my submission-https://ide.codingblocks.com/s/220150

@kumar_sunny,
I don’t think you have understood the problem correctly, the problem is asking for largest contiguous subsequence sum in [l,r], your code will not give that.
Think of what to store in a node of segment tree, so that the value of largest contiguous subsequence can be calculated for [l,r] i.e the range the node represents.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.