Can anyone give some ideas about how can this problem be solved using Segment Trees OR any other data structure.
I have already spent more than 3 hours on this problem but I could not figure out any approach. Also I am unable to understand the editorial given :(.
Any help is appreciated !.