- 传纸条
- 2009-11-08 11:36:58 @
program ex;
var
f:array[0..101,0..51,0..51] of longint;
a:array[1..50,1..50] of longint;
m,n,i,j,k,x1,x2,y1,y2,t,x:longint;
function min(a,b:longint):longint;
begin
if ab then exit(a) else exit(b);
end;
begin
readln(m,n);
for i:=1 to m do
begin
for j:=1 to n do read(a);
readln;
end;
fillchar(f,sizeof(f),0);
f[1,1,1]:=a[1,1];
for k:=2 to n+m-1 do
begin
x:=min(k,n);
for x1:=1 to x do
for x2:=1 to x do
if (x1x2) or (k=m+n-1) then
begin
y1:=k-x1+1;y2:=k-x2+1;
t:=a[x1,y1]+a[x2,y2];
for i:=-1 to 0 do
for j:=-1 to 0 do
f[k,x1,x2]:=max(f[k-1,x1+i,x2+j]+t,f[k,x1,x2]);
end;
end;
writeln(f[n+m-1,n,n]);
end.
0 条评论
目前还没有评论...