比赛 20120330 评测结果 AAAAAAAAAA
题目名称 导弹系统 最终得分 100
用户昵称 苏轼 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2012-03-30 22:23:06
显示代码纯文本
#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;
}