比赛 20111102 评测结果 ATAAAAAAAAA
题目名称 麻烦的聚餐 最终得分 90
用户昵称 苏轼 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2011-11-02 20:24:10
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#define max(a,b) ((a)>=(b)?(a):(b))
using namespace std;
int w[30010],number,q[30010];
int main()
{
	freopen ("egroup.in","r",stdin);
	freopen ("egroup.out","w",stdout);
	scanf("%d",&number);
	for (int i=0;i<number;i++)
	{
		scanf("%d",&w[i]);
	}
	int answer=0;
	for (int i=0;i<number;i++)
	{
		q[i]=1;
	}
	for (int i=number-2;i>=0;i--)
	{
		for (int j=i+1;j<number;j++)
		{
			int temp=0;
			if (w[j]>=w[i])
			{
				q[i]=max(q[i],q[j]+1);
			}
		}
		if (q[i]>answer)
		{
			answer=q[i];
		}
	}
	for (int i=0;i<number/2;i++)
	{
		int temp;
		temp=w[i];
		w[i]=w[number-1-i];
		w[number-1-i]=temp;
	}
	for (int i=0;i<number;i++)
	{
		q[i]=1;
	}
	for (int i=number-2;i>=0;i--)
	{
		for (int j=i+1;j<number;j++)
		{
			int temp=0;
			if (w[j]>=w[i])
			{
				q[i]=max(q[i],q[j]+1);
			}
		}
		if (q[i]>answer)
		{
			answer=q[i];
		}
	}
	cout<<number-answer;
	return 0;
}