hdu 2037 今年暑假不AC

来源:互联网 发布:最真实的网络射击游戏 编辑:程序博客网 时间:2024/05/17 01:13
#include<iostream>#include<cstdio>#include<algorithm>using namespace std;struct Time{int s,e;}time[200];int cmp(Time a,Time b){return a.e<b.e;}int main(){int n;int m;int cnt;int i;while( scanf("%d",&n)!=EOF ){if(n==0)break;for(i=0;i<n;i++){scanf("%d%d",&time[i].s,&time[i].e);}sort(time,time+n,cmp);m=time[0].e;cnt=1;for(i=1;i<n;i++){if(time[i].s>=m){m=time[i].e;cnt++;}}printf("%d\n",cnt);}return 0;}

0 0
原创粉丝点击