/ Vijos / 讨论 / 分享 /

大牛 给看看 方块取数 看了Rp+20!

var n,i,j,k:longint;

data:array[1..8,1..8] of longint;

f:array[0..50,0..50,0..50] of longint;

a,b,c:longint;

function min(v1,v2:longint):longint;

begin if v1>v2 then exit(v2);

exit(v1);

end;

function max(v1,v2,v3,v4:longint):longint;

begin if (v4>=v1) and (v4>=v3) and (v4>=v2) then exit(v4);

if (v3>=v1) and (v3>=v2) and (v3>=v4) then exit(v3);

if (v2>=v1) and (v2>=v3) and (v2>=v4) then exit(v2);

if (v1>=v2) and (v1>=v3) and (v1>=v4) then exit(v1);

end;

procedure init;

begin readln(n);

readln(a,b,c);

while a0 do

begin

readln(a,b,c);

if a=0 then exit;

data[a,b]:=c;

end;

end;

procedure main;

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

for k:=1 to 2*n-1 do

begin

for i:=1 to min(n,k) do

for j:=i+1 to min(n,k) do

f[k,i,j]:=max(f[k-1,i,j],f[k-1,i-1,j],f[k-1,i-1,j-1],f[k-1,i,j-1])+data+data[j,k-j+1];

end;

writeln(f[2*n-1,n,n-1]+f[2*n-1,n-1,n]);

end;

begin

init;

main;

end.

百思不得其解 Why wrong answer? Why?

0 条评论

目前还没有评论...