很囧的只有六十……可是不明白为什么

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 条评论

目前还没有评论...

信息

ID
1493
难度
5
分类
动态规划 点击显示
标签
递交数
6711
已通过
2508
通过率
37%
被复制
9
上传者