记录编号 |
38245 |
评测结果 |
AAAAAAAAAA |
题目名称 |
导弹系统 |
最终得分 |
100 |
用户昵称 |
苏轼 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.072 s |
提交时间 |
2012-04-16 16:34:16 |
内存使用 |
0.34 MiB |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
int n;
int main()
{
freopen ("missilea.in","r",stdin);
freopen ("missilea.out","w",stdout);
while (cin>>n&&n)
{
int q[10001][4]={0};
for (int i=1;i<=n;i++)
{
q[i][1]=1;
q[i][2]=1;
q[i][3]=0;
}
for (int i=1;i<=n;i++)
cin>>q[i][0];
int answer=1;
q[1][3]=1;
for (int i=2;i<=n;i++)
{
for (int j=1;j<i;j++)
{
if (q[i][0]>q[j][0])
{
if (q[j][3]%2==1)
{
q[i][3]=max(q[j][3],q[i][3]);
continue;
}
q[i][2]=max(q[j][1]+1,q[i][2]);
q[i][3]=max(q[j][3]+1,q[i][2]);
if (q[i][2]>answer)
answer=q[i][2];
}
if (q[i][0]<q[j][0])
{
if (q[j][3]%2==0)
{
q[i][3]=max(q[j][3],q[i][3]);
continue;
}
q[i][1]=max(q[j][2]+1,q[i][1]);
q[i][3]=max(q[j][3]+1,q[i][2]);
if (q[i][1]>answer)
answer=q[i][1];
}
}
}
cout<<answer<<endl;
}
return 0;
}