How to solve this segment tree problem?

CodeChef: Practical coding for everyone .
Can anyone give an approach to solve this segment tree problem.