HackerEarth Problem

Need help regarding this Segment Tree based problem:-

easiest way to solve it is using binary search on list of indexes having 1
u can use lower bound on set if using c++