http://acm.hdu.edu.cn/showproblem.php?pid=2037
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef struct
{
int begin;
int end;
}Game;
Game aa[101];
bool cmp(Game a,Game b)
{
if(a.end<b.end)
return true;
else
return false;
}
int main()
{
int T;
while(scanf("%d",&T),T)
{
for(int i=0;i<T;i++)
scanf("%d%d",&aa[i].begin,&aa[i].end);
sort(aa,aa+T,cmp);
int max=1,temp=0;
for(int i=1;i<T;i++)
{
if(aa[temp].end<=aa[i].begin)
{
temp=i;
max++;
}
printf("%d\n",max);
}
return 0;
}