标签:io for amp on print ca include c
#include<stdio.h>
#include<stdlib.h>
int main()
{
int students,max=0;
int i,j;
int a[100],b[100],c[100];
scanf("%d",&students);
for(i=0;i<students;i++)
scanf("%d",&a[i]);
for(i=0;i<students;i++) //寻找从左边开始的最长上升子序列
{
b[i]=1;
for(j=0;j<i;j++)
if(a[j]<a[i]&&b[j]+1>b[i])
b[i]=b[j]+1;
}
for(i=students-1;i>=0;i--) //寻找从右边开始的最长上升子序列
{
c[i]=1;
for(j=i+1;j<students;j++)
if(a[j]<a[i]&&c[j]+1>c[i])
c[i]=c[j]+1;
}
for(i=0;i<students;i++)//求以a[i]为最高点的最长合唱队列(a[i]被重复计算一次,所以后面要+1)
if(c[i]+b[i]>max)
max=c[i]+b[i];
printf("%d",students-max+1);//输出总人数-合唱队列人数+1(被重复计算的a[i])
}
合唱队形 九度1131 RONOJ26,布布扣,bubuko.com
标签:io for amp on print ca include c
原文地址:http://www.cnblogs.com/2014acm/p/3907925.html