2206: 区间合并

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:2 Solved:1

Description

给定 n 个区间 [li, ri],要求合并所有有交集的区间。注意如果在端点处相交,也算有交集。输出合并完成后的区间个数。

例如:[1,3] [2,6]可以合并为一个区间 [1,6]

Input

第一行包含整数 n

接下来 n 行,每行包含两个整数 l  r

Output

共一行,包含一个整数,表示合并区间完成后的区间个数。

Sample Input Copy

5
1 2
2 4
5 6
7 8
7 9

Sample Output Copy

3

Source/Category