HDOJ2037

/*节目越早结束,就能看越多节目*/
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;


#define M 1005
int num[M] = { 0 };


struct aa
{
int s, e;
}a[M];


bool cmp(aa a, aa b)
{
return a.e < b.e;
}


int main()
{
int n;
while (cin >> n, n)
{
int sum = 1,j=0;
for (int i = 0; i < n; i++) cin >> a[i].s >> a[i].e;
sort(a, a + n, cmp);
for (int i = 1; i < n; i++)
{
if (a[i].s >= a[j].e)
{
sum++;
j = i;
}
}
cout << sum << endl;
}
}
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页