http://acm.hdu.edu.cn/showproblem.php?pid=2037
#include <iostream>
#include <algorithm>
using namespace std;
typedef struct//结构体排序,对节目结束时间早晚排序
{
int s,e;
}tv;
int compare(tv a,tv b)
{
return a.e < b.e;
}
int main()
{
int n;
tv a[1001];
while(cin >> n)
{
if(n == 0)
return 0;
for(int i = 0;i < n;i++)
{
cin >> a[i].s >> a[i].e;
}
sort(a,a+n,compare);
int finish = a[0].e;
int cnt = 1;
for(int i = 1;i < n;i++)
{
if(finish <= a[i].s)
{
cnt++;
finish = a[i].e;
}
}
cout << cnt << "\n";
}
return 0;
}