SPOJ problem GSS1, find the problem here
How to exactly make the query?
I have stored best, lsum, rsum and total sum in each node of segment tree.
Code should be helpful.
Thanks in advance.
SPOJ problem GSS1, find the problem here
How to exactly make the query?
I have stored best, lsum, rsum and total sum in each node of segment tree.
Code should be helpful.
Thanks in advance.
Your method of query is not corerct
Have a look at it.
Is this always true?
consider this test case :
6
1 -2 3 4 -1 6
6
1 3
2 6
1 6
4 6
5 6
3 5
As @shukrant said always returning max of left and right subtree is not correct.
A hint : It has something to do with the lsum and rsum variable of your code.
BTW Your code was really clean and easy to understand.
Great
If you need more help I can give you my code, but trying yourself first would be better I guess