Segment tree max query1

Problem is max query-I from segment tree section.
My code- https://ide.codingblocks.com/s/296101
Getting TLE . What I have been doing wrong ? It works for the given sample test case though.