/ Vijos / 讨论 / 问答 /

管理员来看,提交问题!

P1098

Program P1098;

Const maxn=100;

Var n:longint;

   a,fup,fdown:array[0..maxn+1] of longint;

Procedure init;

Var i:longint;

Begin

readln(n);

for i:=1 to n do read(a[i]);

End;

Procedure work;

Var i,j:longint;

   sum,max,maxi,max1:longint;

Begin

for i:=1 to n do

  begin

   fup[i]:=1;

   fdown[i]:=1;

  end;

for i:=n downto 1 do

  begin

   max:=0;

   for j:=i+1 to n do

   if (a[j]>a[i]) and (fup[j]>max) then max:=fup[j];

   fup[i]:=fup[i]+max;

  end;

for i:=1 to n do

  begin

   max:=0;

   for j:=1 to i-1 do

   if (a[i]max) then max:=fdown[j];

   fdown[i]:=fdown[i]+max;

  end;

max:=0;

for i:=1 to n do

  begin

   if fup[i]+fdown[i]>max then max:=fup[i]+fdown[i];

  end;

writeln(n-max+2);

End;

Begin

init;

work;

End.

提交三次

R1405628 No Compiled

0

From Procedure-  P1098

FPC

Vivid Puppy

2009-8-9 15:20:28

R1405622 No Compiled

0

From Procedure-  P1098

FPC

Vivid Puppy

2009-8-9 15:18:21

R1405618 No Compiled

0

From Procedure-  P1098

FPC

Vivid Puppy

2009-8-9 15:17:1

再一次查看之前提交的内容变成这样。

Program P1098; Const maxn=100; Var n:longint;   a,fup,fdown:array[0..maxn+1] of longint; Procedure init; Var i:longint; Begin readln(n); for i:=1 to n do read(a[i]); End; Procedure work; Var i,j:longint;   sum,max,maxi,max1:longint; Begin for i:=1 to n do  begin   fup[i]:=1;   fdown[i]:=1;  end; for i:=n downto 1 do  begin   max:=0;   for j:=i+1 to n do   if (a[j]>a[i]) and (fup[j]>max) then max:=fup[j];   fup[i]:=fup[i]+max;  end; for i:=1 to n do  begin   max:=0;   for j:=1 to i-1 do   if (a[i]max) then max:=fdown[j];   fdown[i]:=fdown[i]+max;  end; max:=0; for i:=1 to n do  begin   if fup[i]+fdown[i]>max then max:=fup[i]+fdown[i];  end; writeln(n-max+2); End;Begin init; work;End.

1 条评论

  • @ 2009-08-09 20:04:49

    你用的什么浏览器??

    RT,你用的什么浏览器??

  • 1