http://www.luogu.org/record/lists?pid=P1803
把比赛抽象为区间,然后按照区间右边排序,然后选择第一个区间,之后再选择不与第一个区间相交的区间即可,以此例推
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#define ms(i,j) memset(i,j, sizeof i);
using namespace std;
struct qj
{
int a;
int b;
}q[1000005];
bool cmp(qj const &a, qj const &b)
{
if (a.b<b.b) return true;
else if (a.b>b.b) return false;
else return a.a<b.a;
}
int main()
{
int n;
scanf("%d", &n);
for (int i=1;i<=n;i++)
{
scanf("%d%d", &q[i].a, &q[i].b);
}
sort(q+1, q+1+n, cmp);
int end = q[1].b;
int ans = 1;
for (int i=2;i<=n;i++)
{
if (q[i].a>=end)
{
ans++;
end = q[i].b;
}
}
printf("%d\n", ans);
return 0;
}