标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 34165 Accepted Submission(s):
18197
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct record { int begin; int end; }s[110]; bool cmp(record a,record b) { if(a.end!=b.end) return a.end<b.end; else return a.begin>b.begin; } int main() { int n,m,j,i,sum,k; int dp[11000]; while(scanf("%d",&n)&&n!=0) { for(i=0;i<n;i++) scanf("%d%d",&s[i].begin,&s[i].end); sort(s,s+n,cmp); sum=1; k=s[0].end; for(i=1;i<n;i++) { if(k<=s[i].begin) { sum++; k=s[i].end; } } printf("%d\n",sum); } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4524408.html