Sakurako's Painting#372

Sakurako's Painting (Editorial)

The solution to this task is to sort all segments in ascending order of the starting point and try to greedily find the answer. So, from the first segment, we take all points it takes. For the second, all points that are not in the first segment (i.e. some suffix of it), in third all that are not in first or second and so on. In result, we take the maximum number of points, and we will take some (possibly empty) suffix of each segment.