[Help]How can this problem be solved?

I am working on this problem . As I am a newbie in algorithm designing , I wanted to know how can we solve this problem. Please help me in figuring this out in brief.

P.S. - A tutorial can be a great help for many other people like me who wants to learn.

Thanks In Advance.

The solution is pretty straight forward - solution

you can solve it by using segment tree.
For more detail plz see this link:-Topcoder

u can use two segment trees one for min and one for max. thats it done.

brute force passing?? wow