- 传纸条
- 2014-07-29 17:48:57 @
第八个点超时=。=
var
f:array[0..51,0..51,0..51,0..51]of longint;
map:array[0..100,0..100]of longint;
n,m:longint;
procedure prepare;
var
i,j:longint;
begin
readln(n,m);
for i:=1 to n do
for j:=1 to m do
begin
read(map[i,j]);
end;
end;
procedure main;
var
i,j,k,l:longint;
begin
for i:=1 to n do
for j:=1 to m do
for k:=1 to n do
for l:=1 to m do
begin
if f[i-1,j,k-1,l]>f[i,j,k,l] then f[i,j,k,l]:=f[i-1,j,k-1,l];
if f[i-1,j,k,l-1]>f[i,j,k,l] then f[i,j,k,l]:=f[i-1,j,k,l-1];
if f[i,j-1,k-1,l]>f[i,j,k,l] then f[i,j,k,l]:=f[i,j-1,k-1,l];
if f[i,j-1,k,l-1]>f[i,j,k,l] then f[i,j,k,l]:=f[i,j-1,k,l-1];
f[i,j,k,l]:=f[i,j,k,l]+map[i,j];
if (i<>k)and(j<>l) then f[i,j,k,l]:=f[i,j,k,l]+map[k,l];
end;
writeln(f[n,m,n,m]);
end;
begin
prepare;
main;
end.