解题思路:
注意事项:
参考代码:
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1000000;
struct node
{
int start,end;
}a[N];
bool cmp(node x,node y){return x.end<y.end;}
int main()
{
int n;cin>>n;
for(int i=0;i<n;i++)cin>>a[i].start>>a[i].end;
sort(a,a+n,cmp);
int res=1;//第一个也得算进去
int temp=a[0].end;
for(int i=1;i<n;i++)
{
if(temp<=a[i].start)
{
res++;
temp=a[i].end;
}
}
cout<<res<<endl;
return 0;
}
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:468 |
点我有惊喜!你懂得!浏览:1338 |
校门外的树 (C语言代码)浏览:717 |
K-进制数 (C++代码)浏览:858 |
C二级辅导-计负均正 (C语言代码)浏览:598 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:655 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:522 |
奖学金 (C++代码)浏览:2008 |
计算质因子 (C++代码)浏览:1646 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:624 |