12 1 3 3 4 0 7 3 8 15 19 15 20 10 15 8 18 6 12 5 10 4 14 2 9 0
5
#include<iostream>
#include<cstdio>
#include<cstring> //看节目,每次找最先结束的节目
#include<algorithm>
using namespace std;
#define N 105
struct stud{
int s,e;
}f[N];
int cmp(stud a,stud b)
{
return a.e<b.e;
}
int main()
{
int n,i,ans;
while(scanf("%d",&n)!=EOF,n)
{
ans=0;
for(i=0;i<n;i++)
scanf("%d%d",&f[i].s,&f[i].e);
sort(f,f+n,cmp);
int temp=0;
for(i=0;i<n;i++)
if(f[i].s>=temp)
{
ans++;
temp=f[i].e;
}
printf("%d\n",ans);
}
return 0;
}
HDU 2037 今年暑假不AC,布布扣,bubuko.com
原文:http://blog.csdn.net/u014737310/article/details/38493397