比赛 10101115 评测结果 AAAAAAAAAA
题目名称 牛宫 最终得分 100
用户昵称 make 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-15 10:34:13
显示代码纯文本
program long;
var
 n,m,i,j,k,p,ans:longint;
 sum,b:array[0..200]of int64;
 a:array[0..200,0..200]of int64;
 x:int64;
 f1,f2:text;


procedure init;
var i,j:longint;
begin
 assign(f1,'long.in'); reset(f1);
 assign(f2,'long.out'); rewrite(f2);
 readln(f1,n,m);
 for i:=1 to n do
 for j:=1 to m do begin
  read(f1,x);
  a[i,j]:=a[i-1,j]+a[i,j-1]-a[i-1,j-1]+x;
 end;
close(f1);
end;

function calc(i,j,x,y:longint):int64;
begin
 calc:=a[x,y]-a[x,j-1]-a[i-1,y]+a[i-1,j-1];
end;

procedure play;
var i,j:longint;
begin
 for i:=1 to m do
  for j:=i to m do
   begin
    for k:=1 to n do sum[k]:=calc(1,i,k,j);
     for k:=1 to n do
      if sum[k]>sum[k-1] then begin
       b[k]:=k;
       for p:=0 to b[k-1] do
        if sum[p]<sum[k] then begin
         b[k]:=p;
         if (k-p)*(j-i+1)>ans then ans:=(k-p)*(j-i+1);
         break;
        end;
       end
      else begin
       b[k]:=k;
       for p:=b[k-1] to k-1 do
        if sum[p]<sum[k] then
         begin
          b[k]:=p;
          if (k-p)*(j-i+1)>ans then ans:=(k-p)*(j-i+1);
          break;
         end;
            end;
   end;
end;

begin
 init;
 play;
 writeln(f2,ans);
 close(f2);
end.