Help me in solving DELISH problem

Is there a solution to this problem with the segment tree??
If so, can you send solution of the problem? please
Problem Link: DELISH Problem - CodeChef