比赛 |
20121009 |
评测结果 |
WWWWW |
题目名称 |
木棍 |
最终得分 |
0 |
用户昵称 |
苏轼 |
运行时间 |
0.166 s |
代码语言 |
C++ |
内存使用 |
3.22 MiB |
提交时间 |
2012-10-09 21:58:30 |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int n,m,ans[10000]={0},answer=0;
struct hehe
{
int length,time;
}q[5005];
int cmp( const void *a , const void *b )
{
struct hehe *c = (hehe *)a;
struct hehe *d = (hehe *)b;
if(c->length != d->length) return c->length - d->length;
else return c->time - d->time;
}
int main()
{
freopen ("wooden.in","r",stdin);
freopen ("wooden.out","w",stdout);
cin>>n;
for (int i=0;i<n;i++)
{
cin>>q[i].length>>q[i].time;
ans[i]=1;
}
qsort(q,n,sizeof(q[0]),cmp);
for (int i=n-1;i>=0;i--)
{
for (int j=i;j<n;j++)
{
if (q[i].time>q[j].time&&ans[j]>ans[i])
{
ans[i]=ans[j]+1;
}
}
if (ans[i]>answer)
answer=ans[i];
}
cout<<answer;
return 0;
}