atcoder#ABC256D. [ABC256D] Union of Interval
[ABC256D] Union of Interval
Score : points
Problem Statement
For real numbers and , let us denote by the set of real numbers greater than or equal to and less than . Such a set is called a right half-open interval.
You are given right half-open intervals . Let be their union. Represent as a union of the minimum number of right half-open intervals.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Let be the minimum number of right half-open intervals needed to represent as their union. Print lines containing such right half-open intervals in ascending order of , as follows:
3
10 20
20 30
40 50
10 30
40 50
The union of the three right half-open intervals equals the union of two right half-open intervals .
3
10 40
30 60
20 50
10 60
The union of the three right half-open intervals equals the union of one right half-open interval .