讨论 / pascal只过了2个点!求助!!!(另:手贱用了5个过程,别吐槽)
as446650818 2013-07-02 09:10:00
点我顶贴 收藏 删除
var f,g,g1:array[1..100]of longint;

l,m,n,i,j,k,max,max1,zenmax,gomax:longint;

procedure duru;

begin

readln(m);

for j:=1 to m do

read(f[j]);

end;

procedure saidainowa;

var x:longint;

begin

max:=0;

for i:=1 to m do

if f[i]>x then begin x:=f[i]; max:=i; end;

end;

procedure ironyup;

begin

g[max]:=1;

for i:=max-1 downto 1 do

begin

max1:=0;

j:=i;

while j<max do

begin

if f[i]<f[j+1] then

if g[i]<g[j+1]+1 then

begin

g[i]:=g[j+1]+1;

max1:=g[i];

end;

inc(j);

end;

end;

max1:=0;

for j:=1 to max do

if g[j]>max1 then begin max1:=g[j]; zenmax:=g[j]; end;

end;

procedure ironydown;

begin

g[max]:=1;

for i:=max+1 to m do

begin

max1:=0;

j:=i;

while j>max do

begin

if f[i]>f[j-1] then

if g[i]>g[j-1]+1 then

begin

g[i]:=g[j-1]+1;

max1:=g[i];

end;

dec(j);

end;

end;

max1:=0;

for j:=max+1 to m do

if g[j]>max1 then begin max1:=g[j]; gomax:=g[j]; end;

end;

procedure xiechu;

begin

write(m-gomax-zenmax);

end;

begin

duru;

saidainowa;

ironyup;

ironydown;

xiechu;

end.

查看更多回复
提交回复