讨论 / ti
wuzw 2011-11-23 17:54:00
点我顶贴 收藏 删除
var i,j,i1,j1,i2,j2,m,n:integer;

w:array[0..50,0..50]of integer;

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

function max(i,j,x,y:longint):longint;

begin

max:=i;

if j>max then max:=j;

if x>max then max:=x;

if y>max then max:=y;

end;

begin

readln(n);

repeat

read(i,j);

read(w[i,j]);

until i=0;

for i1:=1 to n do

for j1:=1 to n do

for i2:=1 to i1+j1 do

begin

j2:=i1+j1-i2;

f[i1,j1,i2,j2]:=max(f[i1-1,j1,i2-1,j2],f[i1,j1-1,i2,j2-1],f[i1-1,j1,i2,j2-1],

f[i1,j1-1,i2-1,j2])+w[i1,j1]+w[i2,j2];

end;

writeln(f[m,n,m,n]);

readln

end.

查看更多回复
提交回复