Type: Default 1000ms 256MiB

活动选择

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

学校在最近几天有$n$个活动,这些活动都需要使用学校的大礼堂,在同一时间,礼堂只能被一个活动使用。由于有些活动时间上有冲突,学校办公室人员只好让一些活动放弃使用礼堂而使用其他教室。

现在给出$n$个活动使用礼堂的起始时间$begin\_i$和结束时间$end\_i(begin\_i < end\_i)$,请你帮助办公室人员安排一些活动来使用礼堂,要求安排的活动尽量多。

Input Format

第一行一个整数$n(n≤1000)$;

接下来的$n$行,每行两个整数,第一个$begin\_i$,第二个是$end\_i(begin\_i< end\_i ≤32767)$。

Output Format

输出最多能安排的活动个数。

11
3 5
1 4
12 14
8 12
0 6
8 11
6 10
5 7
3 8
5 9
2 13

4