求助,40分

var

t:array[1..10000]of longint;

c,d,e,n:longint;

begin

read(n);

for c:=1to n do begin

read(t[c]);

if t[c]>t[c-1] then d:=c;

end;

c:=0;

for e:=1 to (d-1) do

if t[e]>=t[e+1] then c:=c+1;

for e:=d to n do

if t[e]

2 条评论

  • @ 2014-07-20 16:49:22

    Free Pascal Compiler version 2.6.2 [2013/02/12] for i386
    Copyright (c) 1993-2012 by Florian Klaempfl and others
    Target OS: Win32 for i386
    Compiling foo.pas
    Linking foo.exe
    42 lines compiled, 0.2 sec , 28528 bytes code, 1628 bytes data
    测试数据 #0: Accepted, time = 0 ms, mem = 612 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 608 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 616 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 612 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 608 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 616 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 612 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 612 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 612 KiB, score = 10
    测试数据 #9: Accepted, time = 15 ms, mem = 616 KiB, score = 10
    Accepted, time = 15 ms, mem = 616 KiB, score = 100
    代码
    var
    n,i,j,ans:longint;
    f,g,h:array[1..200]of longint;
    procedure init;
    begin
    readln(n);
    for i:=1 to n do
    begin
    read(h[i]);
    f[i]:=1;g[i]:=1;
    end;
    end;

    procedure dpone;
    begin
    for i:=1 to n-1 do
    for j:=i+1 to n do
    if (h[i]<h[j]) and (f[i]>=f[j]) then f[j]:=f[i]+1;
    end;

    procedure dptwo;
    begin
    for i:=n downto 2 do
    for j:=i-1 downto 1 do
    if (h[i]<h[j]) and (g[i]>=g[j]) then g[j]:=g[i]+1;

    end;

    procedure print;
    begin
    ans:=0;
    for i:=1 to n do
    if ans<f[i]+g[i] then ans:=f[i]+g[i];
    ans:=n-ans+1;
    writeln(ans);
    end;

    begin
    init;
    dpone;
    dptwo;
    print;
    end.

  • @ 2013-10-11 08:16:48

    你这个的大方向就错了。这题只要正着、反着做两次动归就行了。

  • 1

信息

ID
1098
难度
5
分类
动态规划 | LIS 点击显示
标签
递交数
12832
已通过
4890
通过率
38%
被复制
21
上传者