MAX QUERY-I --- giving wrong ans --- segment tree

https://ide.codingblocks.com/s/71259
i store sorted array in nodes of segment tree
an use lower bound to get ans in complete query

While Building your tree
you are storing complete array of given range at that node.
In worst case, it will overflow the memory constraint of the problem.
This is a new concept question of offline queries in Segment Tree.
Try to read offline queries in segment tree (KQUERY SPOJ SOLUTION) and solve accordingly.
If any more problem regarding approach , reply here.

and
you are getting wrong answer , then most probably you could have done some mistake in segment tree.otherwise you should get run time error (due to memory constraint)

If your doubt is resolved then pleas mark it as resolved in your online course’s ask doubt section.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.