303 条题解
-
-1
西门吹牛 LV 3 @ 18 年前
纪念一下
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms -
-28 年前@
-
-28 年前@
利用动归,求两次
program jj;
var a,b,c:array[1..100]of integer;
max,n,i,j:integer;
begin
// assign(input,'in.txt'); assign(output,'out.txt');
//reset(input);rewrite(output);
readln(n);
for i:=1 to n do
begin
read(a[i]);b[i]:=1;c[i]:=1;
end;
for i:=1 to n do
begin
for j:=1 to i-1 do
if (a[i]>a[j])and (b[i]<=b[j]) then
b[i]:=b[j]+1;
end;
for i:=n downto 1 do
begin
for j:=n downto i+1 do
if (a[i]>a[j])and (c[i]<=c[j]) then
c[i]:=c[j]+1;
end;
max:=0;
for i:=1 to n do
if (c[i]+b[i]>max) then
max:=c[i]+b[i];
writeln(n-max+1);
//close(input);close(output);
end.