SPOJ GSS1 Segment tree

I am getting a SIGSEGV for Spoj GSS1

my solution → HPev59 - Online C++ Compiler & Debugging Tool - Ideone.com

Please help !!