标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 35614 Accepted Submission(s): 18987
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 6 struct as 7 { 8 int begin; 9 int end; 10 11 } aa[104]; 12 13 bool cmp(as x,as y) 14 { 15 return x.end<y.end;//结束时间排序 16 } 17 int main() 18 { 19 int N,i; 20 while(scanf("%d",&N),N) 21 { 22 23 24 for(i=0;i<N;i++) 25 scanf("%d%d",&aa[i].begin,&aa[i].end); 26 sort(aa,aa+N,cmp); 27 int cot=1,tim=aa[0].end;//排在第一个,肯定要选 28 for(i=1;i<N;i++) 29 { 30 if(aa[i].begin>=tim) 31 { 32 tim=aa[i].end; 33 cot++; 34 } 35 } 36 printf("%d\n",cot); 37 } 38 } 39
标签:
原文地址:http://www.cnblogs.com/Eric-keke/p/4695930.html