文章
211
粉丝
1
获赞
1151
访问
42.2k
#include <bits/stdc++.h>
using namespace std;
struct node {
int st, ed;
};
bool cmp(node x, node y) {
return x.ed < y.ed;
}
int main() {
int n;
cin >> n;
vector<node> a(n+1);
for (int i = 1; i <= n; i++)
cin >> a[i].st >> a[i].ed;
sort(a.begin(),a.end(),cmp);
int t = a[1].ed;
int ans = 1;
for (int i = 2; i <= n; i++) {
if (t <= a[i].st) {
ans++;
t = a[i].ed;
}
}
cout << ans << endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发