Getting tle in MAX QUERY problem of segment trees

sir,i hav applied the same logic as taught in hint video…still i am getting tle…
here is the link to my solution:

plz help!!

Maybe problem is in merging.
Use STL merging , refer this -:

sir…i passed all vectors by reference…then it worked…thanks btw!!.