answer has to be in C++ or Java covering segments by points Given n segments, find the minimal possible number of points such that each segment contains at least one point. The first line contains the number 1≤n≤100 of segments. Each of the following n li

answer has to be in C++ or Java covering segments by points Given n segments, find the minimal possible number of points such that each segment contains at least one point. The first line contains the number 1≤n≤100 of segments. Each of the following n lines contains two integers 0≤l≤r≤109 defining the endpoints of a segment. Output the optimal number m of points and then m points. 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 Memory Limit: 256 MB Time Limit: 1 seconds