怎么优化啊

Program p1255;

Var

n,m,i,j,k,l,ans:longint;

a:array[1..300,1..300] of integer;

tmp:array[1..300,0..300] of longint;

f:array[0..300,0..300] of longint;

Begin

readln(n,m);

for i:=1 to n do

begin

tmp:=0;

for j:=1 to m do

begin

read(a);

if a=0 then a:=-maxint;

tmp:=tmp+a;

end;

readln;

end;

for i:=1 to n do

for j:=1 to m do

for k:=1 to i do

inc(f,tmp[k,j]);

ans:=0;

for i:=1 to n do

for j:=1 to m do

for k:=i to n do

for l:=j to m do

if (f+f[k,l]-f-f[k,j-1])>ans then ans:=f+f[k,l]-f-f[k,j-1];

writeln(ans);

End.

0 条评论

目前还没有评论...

信息

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