- 合唱队形
- 2012-10-21 11:23:35 @
var
02 a,b,c:array[1..100] of integer;
03 q,k,n,ans:integer;
04 begin
05 readln(n);
06 for q:=1 to n do read(a[q]);
07 fillchar(b,sizeof(b),0);
08 fillchar(c,sizeof(c),0);
09 for q:=1 to n do
10 begin
11 b[q]:=1;
12 for k:=1 to q-1 do
13 if (a[q]>a[k]) and (b[k]+1>b[q]) then b[q]:=b[k]+1;
14 end;
15 for q:=n downto 1 do
16 begin
17 c[q]=1;
18 for k:=q+1 to n do
19 if (a[q]>a[k]) and (c[k]+1>c[q]) then c[q]:=c[k]+1;
20 end;
21 ans:=0;
22 for q:=1 to n do
23 if (b[q]+c[q]>ans) then ans:=b[q]+c[q];
24 ans:=n-ans+1;
25 write(ans);
26 end.
0 条评论
目前还没有评论...