比赛 |
20121009 |
评测结果 |
AAAAA |
题目名称 |
木棍 |
最终得分 |
100 |
用户昵称 |
TBK |
运行时间 |
0.015 s |
代码语言 |
C++ |
内存使用 |
3.18 MiB |
提交时间 |
2012-10-09 20:02:45 |
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
int a,b,c,d,l,s;
struct fun
{
int x,y;
}f[5001];
int Compare(const void*elem1,const void*elem2)
{
struct fun *elem3=(struct fun *)elem1;
struct fun *elem4=(struct fun *)elem2;
if (elem3->x != elem4 ->x) return elem3->x - elem4->x;
else return elem3->y- elem4->y;
}
int main(void)
{
freopen ("wooden.in","r",stdin);
freopen ("wooden.out","w",stdout);
scanf("%d",&a);
for (b=0;b<a;b++) scanf("%d%d",&f[b].x,&f[b].y);
qsort(f,a,sizeof(fun),Compare);
c=f[0].y;
d=0;
while (d!=-1&&c!=-1)
{
for (b=1;b<a;b++)
if (f[b].y>=c)
{
c=f[b].y;
f[d].y=-1;
d=b;
}
f[d].y=-1;
s++;
c=-1;
d=-1;
for (b=1;b<a;b++)
if (f[b].y!=-1)
{
c=f[b].y;
d=b;
break;
}
}
printf("%d",s);
fclose(stdin);
fclose(stdout);
return 0;
}