Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.007 s | 2 KBi |
#2 |
Correcto
|
0.006 s | 1 KBi |
#3 |
Correcto
|
0.006 s | 1 KBi |
#4 |
Correcto
|
0.004 s | 2 KBi |
#5 |
Correcto
|
0.006 s | 1 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.004 s | 1 KBi |
#8 |
Correcto
|
0.068 s | 1 KBi |
#9 |
Correcto
|
0.061 s | 2 KBi |
#10 |
Correcto
|
0.057 s | 2 KBi |
#11 |
Correcto
|
0.071 s | 1 KBi |
#12 |
Correcto
|
0.048 s | 2 KBi |
#13 |
Correcto
|
0.07 s | 1 KBi |
#14 |
Correcto
|
0.076 s | 2 KBi |
#15 |
Correcto
|
0.08 s | 2 KBi |
#16 |
Correcto
|
0.055 s | 2 KBi |
#17 |
Correcto
|
0.061 s | 2 KBi |
#18 |
Correcto
|
0.05 s | 1 KBi |
#include <bits/stdc++.h> #define fi first #define se second #define forn(i,n) for(int i=0; i< (int)n; ++i) #define for1(i,n) for(int i=1; i<= (int)n; ++i) #define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i) #define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i) #define fored(i,l,r) for(int i=(int)r; i>= (int)l; --i) #define pb push_back #define el '\n' #define d(x) cout<< #x<< " " << x<<el #define ri(n) scanf("%d",&n) #define sz(v) ((int)v.size()) #define all(v) v.begin(),v.end() #define allr(v) v.rbegin(),v.rend() using namespace std; typedef long long ll; typedef double ld; typedef pair<int,int> ii; typedef pair<char,int> pci; typedef tuple<int, int, int> tiii; typedef pair<ll,ll> pll; typedef vector<int> vi; const int inf = 1e9; const int nax = 1e5+200; const ld pi = acos(-1); const ld eps= 1e-9; int dr[] = {1,-1,0, 0,1,-1,-1, 1}; int dc[] = {0, 0,1,-1,1, 1,-1,-1}; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout<< setprecision(20)<< fixed; int n, m; cin>> n>> m; vector<vector<int>> a(n, vector<int>(m,0)), pre; forn(i,n) forn(j,m) cin>> a[i][j]; pre = a; forn(i,n){ int sum = 0; forn(j,m){ sum += pre[i][j]; pre[i][j] = sum; } } forn(j,m){ int sum = 0; forn(i,n){ sum += pre[i][j]; pre[i][j] = sum; } } int mx = a[0][0]; forn(x1,n){ forn(y1,m){ fore(x2, x1, n-1){ fore(y2, y1, m-1){ int cur = pre[x2][y2]; if(x1) cur -= pre[x1-1][y2]; if(y1) cur -= pre[x2][y1-1]; if(x1 && y1) cur += pre[x1-1][y1-1]; mx = max(mx, cur); } } } } cout<< mx<<el; }