解题思路:
注意事项:
参考代码:
#include<bits/stdc++.h>
using namespace std;
struct Node{
int x, y;
}I[1005];
int cmp(Node a, Node b)
{
return a.y < b.y;
}
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
scanf("%d%d", &I[i].x, &I[i].y);
}
sort(I, I + n, cmp);
int ans = 1;
int lasty = I[0].y;
for (int i = 1; i < n; i++)
{
if (I[i].x >= lasty)
{
lasty = I[i].y;
ans++;
}
}
cout<<ans;
return 0;
}
0.0分
1 人评分