https://github.com/bapjiws/cover-segments-with-points
Nailing the planks with a minimal amount of nails
https://github.com/bapjiws/cover-segments-with-points
Last synced: 2 months ago
JSON representation
Nailing the planks with a minimal amount of nails
- Host: GitHub
- URL: https://github.com/bapjiws/cover-segments-with-points
- Owner: bapjiws
- Created: 2015-11-26T06:31:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-26T08:03:48.000Z (over 9 years ago)
- Last Synced: 2025-01-28T16:44:23.349Z (4 months ago)
- Language: Python
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Given n segments, provide a minimal set of points such that each segment contains at least one of these points.
The first input line contains 1 ≤ n ≤ 100 segments.
Each of n successive input lines contains two numbers 0 ≤ l ≤ r ≤ 109 -- segment's endpoints.
The task is to output the optimal amount of m points and these m points themselves.
If there are several such points sets, output any of those.Sample Input 1:
3
1 3
2 5
3 6
Sample Output 1:
1
3
Sample Input 2:
4
4 7
1 3
2 5
5 6
Sample Output 2:
2
3 6