Getting TLE

I am trying the brackets question of SPOJ I have used a segment tree for that purpose but I am getting TLE on that question.
Please help

http://pastebin.com/8LyMDGcV

//