帮忙看看怎么错了

var
  i,j1,j2,n,m,max,x:longint;
    s:array[0..301,0..301]of int64;
    f:array[0..301]of int64;
begin
  fillchar(s,sizeof(s),0);
  readln(n,m);
    for i:=1 to n do
      for j1:=1 to m do
          begin
              read(x);
                if x=0 then x:=-maxlongint;
            s[i,j1]:=s[i-1,j1]+s[i,j1-1]-s[i-1,j1-1]+x;
            end;
    max:=-1;
    for j1:=1 to m do
      for j2:=j1 to m do
          begin
              f[0]:=0;
              for i:=1 to n do
                begin
                    x:=s[i,j2]-s[i,j1-1]-s[i-1,j2]+s[i-1,j1-1];
                    if f[i-1]>0 then f[i]:=f[i-1]+x else f[i]:=x;
                    if f[i]>max then max:=f[i];
                end;
            end;
    write(max);
end.

0 条评论

目前还没有评论...

信息

ID
1255
难度
5
分类
动态规划 | 其他 点击显示
标签
(无)
递交数
1998
已通过
617
通过率
31%
被复制
3
上传者