讨论 / AC pascal 标准代码
潘崇明 2016-02-12 16:55:15
点我顶贴 收藏 删除
var a,f,f1:array[0..1001] of longint;

i,j,k,l,m,n,max:longint;

begin

read(n);

for i:=1 to n do

read(a[i]);

for i:=1 to n do

begin

f[i]:=1;

for j:=1 to i-1 do

begin

if (a[i]>a[j])

and (f[j]+1>f[i])

then f[i]:=f[j]+1;

end;

end;

for i:=n downto 1 do begin

f1[i]:=1;

for j:=i+1 to n do begin

if (a[i]>a[j]) and (f1[j]+1>f1[i]) then f1[i]:=f1[j]+1;

end;

end;

for i:=1 to n do if f[i]+f1[i]>max then max:=f[i]+f1[i];

writeln(n-max+1);

end.

查看更多回复
提交回复