#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n;
struct Seg{
    int a, b;
} c[N];
// c[] 存储每个申请的信息
bool cmp(Seg x, Seg y){
    return x.b < y.b;
}
int main() {
	scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%d%d", &c[i].a, &c[i].b);
    sort(c + 1, c + n + 1, cmp);
    
    int ans = 0, lim = 0;
    // ans存储答案,即能通过的申请个数
    // lim记录“最右界”,即目前通过的申请使用教室最晚到哪节课
    for(int i = 1; i <= n; ++i){
        if(c[i].a >= lim){
            ++ans;
            lim = c[i].b;
        }
    }
    printf("%d\n", ans);
	return 0;
}

原文地址: http://www.cveoy.top/t/topic/h6d9 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录