1 #pragma GCC optimize(2)
2 #pragma GCC optimize(3)
3 #include<bits/stdc++.h>
4 using namespace std;
5
6 int sum[207][207];
7 long long ans;
8 int n,m;
9
10 int main(){
11 scanf("%d %d",&n,&m);
12 for (int i=1;i<=n;i++)
13 for (int j=1;j<=m;j++){
14 scanf("%d",&sum[i][j]);
15 sum[i][j]=sum[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
16 }
17 ans=0;
18 for (int i=1;i<=n;i++)
19 for (int j=1;j<=m;j++)
20 for (int l=i;l<=n;l++)
21 for (int r=j;r<=m;r++)
22 if (ans<sum[l][r]-sum[i-1][r]-sum[l][j-1]+sum[i-1][j-1])
23 ans=sum[l][r]-sum[i-1][r]-sum[l][j-1]+sum[i-1][j-1];
24 printf("%lld",ans);
25 }
1 var
2 sum:array[0..201,0..201] of longint;
3 n,m,ans:longint;
4 procedure init;
5 var
6 i,j:longint;
7 begin
8 readln(n,m);
9 for i:=1 to n do
10 for j:=1 to m do
11 begin
12 read(sum[i,j]);
13 sum[i,j]:=sum[i,j-1]+sum[i,j];
14 end;
15 end;
16
17 function max(o,p:longint):longint;
18 begin
19 if o>p then exit(o);
20 exit(p);
21 end;
22
23 procedure main;
24 var
25 i,j,k,t:longint;
26 begin
27 ans:=0;
28 for i:=1 to m do
29 for j:=i to m do
30 begin
31 t:=0;
32 for k:=1 to n do
33 begin
34 t:=t+sum[k,j]-sum[k,i-1];
35 ans:=max(ans,t);
36 if t<0 then t:=0;
37 end;
38 end;
39 end;
40
41 begin
42 init;
43 main;
44 writeln(ans);
45 end.