http://www.spoj.com/problems/GSS1/ Since this problem is set for segment trees, Kadane's algorithm failed. So I looked up segment trees and got the gist of it. I followed this for learning the basics: https://codeextractor.wordpress.com/2016/07/11/playingwithrangessegmenttree/ After trying few times, I got my code working, but got a WA for final test caes, so I googled up the concept of maximum subarray and managed to get it working, but now my implementation times out, even with optimized IO (beyond scanf and printf, using one of those fancy templates available online) I decided to remove everything, including vectors, and deal purely with arrays and scanf/printfs and I still get a time out. Either the time limit is really strict or the code doesn't work as I think it should and maybe gets stuck. Here is my final implementation using arrays: http://ideone.com/MqeiLa Thanks. asked 20 Dec '16, 06:14

You have done a mistake in your code , make the above function as follows:
The AC solution of your code is here. Here you have to check whether the current node is completely inside the range or not. I have solved the same problem, you can see my solution on github.
answered 20 Dec '16, 07:51

What a silly typo, I didn't even notice it... and here I was trying to optimize IO. Thank you so much, I'll take much better care next time. answered 20 Dec '16, 18:13

can you please explain what actually we have to do i am not able to undesrtand?? stuck between max and all (what is the need)?? answered 01 Feb '18, 21:47

can u plz tell me the approach in this question i m not able to understand what actuall quest wants!! @vijju123 answered 01 Feb '18, 21:59
1
Question asks for maximum sub range sum, just like you calculate maximum sub array sum (u can consider this as range from 0 to n1). Here you have to answer maximum sum in range l to r.
(02 Feb '18, 22:52)
Sorry, saw this late. Refer to what siddharth said :)
(02 Feb '18, 22:59)
