After watching the segment tree video i tried to solve the GSS1 spoj problem.
Problem Link:
My solution:
https://pastebin.com/1GE6DjuF
For the test case
4
-2 1 1 -2
1
1 4
the output must be 2 but my code for some reason prints 0. I cannot figure out the problem with my code. Any help is appreciated.