#T351. 整数区间
整数区间
Description
Please program to complete the following tasks:
- Read the number of closed intervals and their descriptions from a file;
- Find a set with the minimum number of elements such that for every interval, there is at least one integer belonging to this set, and output the number of elements in this set.
Input Format
The first line contains the number of intervals, n, where 1 ≤ n ≤ 10000. The next n lines each contain two integers a and b, separated by a space, where 0 ≤ a ≤ b ≤ 10000, representing the start and end values of a specific interval.
Output Format
The first line should output the number of elements in the set, which must satisfy the condition that for every interval, there is at least one integer belonging to the set, and the set should contain the minimum number of elements.
4
3 6
2 4
0 2
4 7
2