Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int a[51][51],s[51][51];
- int main()
- {
- int n,m,i,j,maxi=-32000;
- cin>>n>>m;
- for (i=1; i<=n; i++)
- for (j=1; j<=m; j++)
- cin>>a[i][j];
- for (i=1; i<=n; i++)
- for (j=1; j<=m; j++)
- s[i][j]=a[i][j]+s[i][j-1]+s[i-1][j]-s[i-1][j-1];
- int x1,x2,y1,y2;
- for (x1=1; x1<=n; x1++)
- for (y1=1; y1<=m; y1++)
- for (x2=x1; x2<=n; x2++)
- for (y2=y1; y2<=m; y2++)
- if (maxi<s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1])
- maxi=s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
- cout<<maxi;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement