← 返回 amazon 的题目列表Merge time intervals from multiple detectors
类型:online_judge
You are given m closed time intervals produced by multiple detectors. Merge them into a list of non-overlapping intervals sorted by start.
Input:
Line 1: integer m
Next m lines: two integers l r representing [l, r]
Output:
First print t, the number of merged intervals
Then print the merged intervals
Constraints:
1 <= m <= 2e5
-1e9 <= l <= r <= 1e9
Example 1 input:
5
1 3
2 6
8 10
15 18
18 20
Output:
3
1 6
8 10
15 20
Example
Input
5
1 3
2 6
8 10
15 18
18 20
Output
3
1 6
8 10
15 20