/ Vijos / 讨论 / 过河 /

请帮帮忙,万分感谢!

帮忙看看哪里错了

全是216

var s,t,l,m,i,j,j0,k:longint;

a:array[0..11000]of boolean;

b:array[0..100]of longint;

f:array[0..11000]of longint;

function min(i,j:longint):longint;

begin

if i>j then exit(j) else exit(i);

end;

{function gong(i,j:byte):integer;

var x:integer;

begin

for x:=i to j do

s:=s*x;

end;}

procedure init;

begin

readln(l);

readln(s,t,m);

fillchar(a,sizeof(a),false);

for i:=1 to m do read(b[i]);

for i:=1 to m-1 do

for j:=i to m do if b[i]>b[j] then begin k:=b[i]; b[i]:=b[j]; b[j]:=k; end;

j0:=0;

for i:=1 to m do

begin

j:=b[i];

k:=j-j0;

if k>100 then k:=100;

l:=l-(j-j0-k);

j0:=j0+k;

a[j0]:=true;

end;

end;

begin

init;

fillchar(f,sizeof(f),0);

f[0]:=0;

for i:=1 to s-1 do f[i]:=maxlongint;

if a then f:=1;

for i:=s+1 to l do

begin

f[i]:=maxint;

for j:=i-t to i-s do f[i]:=min(f[i],f[j]);

if a[i] then f[i]:=f[i]+1;

end;

writeln(f[l]);

end.

1 条评论

  • @ 2009-11-01 21:19:26

    const

    maxl=4000;

    maxm=100;

    var

    l,i,j,ans:longint;

    s,t,m:byte;

    stone:array[0..maxm+1] of longint;

    b:array[1..maxl] of byte;

    f:array[-10..maxl] of longint;

    procedure swap(var a,b:longint);

    var c:longint;

    begin

    c:=a;a:=b;b:=c;

    end;

    function min(a,b:longint):longint;

    begin

    if astone[j]

    then swap(stone[i],stone[j]);

    stone[0]:=0;stone[m+1]:=l;

    for i:=1 to m+1 do

    if stone[i]-stone>90

    then stone[i]:=stone+(stone[i]-stone) mod 90;

    l:=stone[m+1];

    fillchar(b,sizeof(b),0);

    for i:=1 to m do

    b[stone[i]]:=1;

    for i:=-10 to 0 do

    f[i]:=0;

    for i:=1 to l+t do

    f[i]:=maxint;

    for i:=s to l+t do

    for j:=s to t do

    f[i]:=min(f[i],f+b[i]);

    ans:=maxint;

    for i:=l to l+t do

    ans:=min(ans,f[i]);

    writeln(ans);

    end.

  • 1

信息

ID
1002
难度
7
分类
动态规划 点击显示
标签
递交数
25264
已通过
4390
通过率
17%
被复制
76
上传者