#Lutece2854. 观星
观星
Migrated from Lutece 2854 观星
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
夜空中有 颗星星。
但每颗星星只会在一段特定的时间内能被观测到。对于第 颗星星,它能被观测到的时间段为 ,其中 和 都是整数。在每个整数时刻,你都可以选择一颗可以被观测到的星星对它进行拍摄。注意,对于第 颗星星,在时刻 或 你也可以拍摄到它。
现在给你 颗星星可以被观测到的时间段,问从时刻 开始,你最多可以拍摄到多少颗不同的星星?
Input
第一个行是一个整数 ,表示有 颗星星。
接下来 行,每行有两个数字 和 ,表示第 颗星星可以在时间段 被观测到。
Output
一个整数,表示最多可以拍摄到的不同星星数。
Samples
4
1 1
1 2
2 2
2 3
3
5
2 3
1 2
3 3
3 4
1 5
5
Resources
The 19th UESTC Programming Contest Preliminary