70分WA 3个点求大佬看代码

回复帖子

@zdr0820 2018-01-13 11:27 回复
uses math;
var
    a:array[1..50,1..50] of longint;
    n,m,i,j,k,t:longint;
    dp:array[0..51,0..51,0..51] of longint;
begin
    readln(n,m);
    for i:=1 to n do
      for j:=1 to m do
        read(a[i,j]);
    for i:=1 to n do
      for j:=1 to m do
        for k:=1 to n do begin
          dp[i,j,k]:=max(max(dp[i-1,j,k-1],dp[i-1,j,k]),max(dp[i,j-1,k-1],dp[i,j-1,k]))+a[i,j]+a[k,i+j-k];
          if i=k then dec(dp[i,j,k],a[i,j]);
        end;
    writeln(dp[n,m-1,n-1]);
end.