http://acm.nyist.net/JudgeOnline/problem.php?pid=14&rec=sim
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 10010
struct jiemu
{
int s,e;
}a[N];
int cmp(jiemu j,jiemu k) //按节目结束时间升序排列,前面节目较早结束,后面才有较多的选择权
{
return j.e<k.e;
}
int main()
{
int T,n,i,tem,sum;
cin>>T;
while(T--)
{
sum=1;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i].s>>a[i].e;
}
sort(a,a+n,cmp);
tem=a[0].e;
for(i=1;i<n;i++)
{
if(a[i].s>=tem+1)
{
tem=a[i].e;
sum++;
}
}
cout<<sum<<endl;
}
return 0;
}