Interval coverage issue summary (greedy)

1. The request is included between one section to another cell: Both sections are sorted press the right end, the left end of each comparison point is included can be.
2. The minimum interval covered a length: increment to the left point, right point if the same point is also left in ascending order (descending is the same), each such greedy selected from:
recording the farthest distance to cover mx, skip right point of less than where mx is equal, the left end is selected from a point just within the range mx, and the right end point of the line segment farthest.
Analog click.
3. Select a point as little as possible, all to cover all segments: the left end point increment, the right end is incremented each time the greedy next discharge point, so that it is placed in a plurality of overlapping portions of the segments, if a segment of the left end point out of range, ans ++.
Take note of this situation:
-------
   -
      -----
second line segments can be significantly narrowed, so to record the current range of selected point, the right point to a range of smaller updates inside.
------
       ------
this case obviously would be ans ++, right below that point become a a.
4. selecting a plurality of sections, such that no common intersection zone:
Error: ascending order in accordance with the left point, right point then in ascending order.
Counterexample:
---------
  -
     -
chose the first interval, the latter two have no chance.
Positive Solutions: Press the right endpoint in ascending order, press the left point in ascending order.
Summary: In addition to the fourth, you can press the left end by a single sort, then greedily election.
More detail to prove: https: //www.cnblogs.com/acgoto/p/9824723.html

Guess you like

Origin www.cnblogs.com/mowanying/p/11815979.html
Recommended