Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 3 KBi |
#2 |
Correcto
|
0.005 s | 2 KBi |
#3 |
Correcto
|
0.006 s | 8 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 2 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.005 s | 1 KBi |
#8 |
Correcto
|
0.016 s | 1 KBi |
#9 |
Correcto
|
0.025 s | 1 KBi |
#10 |
Correcto
|
0.026 s | 1 KBi |
#11 |
Correcto
|
0.017 s | 1 KBi |
#12 |
Correcto
|
0.015 s | 1 KBi |
#13 |
Correcto
|
0.016 s | 1 KBi |
#14 |
Correcto
|
0.027 s | 1 KBi |
#15 |
Correcto
|
0.027 s | 1 KBi |
#16 |
Correcto
|
0.015 s | 2 KBi |
#17 |
Correcto
|
0.027 s | 1 KBi |
#18 |
Correcto
|
0.015 s | 1 KBi |
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long const int maxi = 60; ll a[maxi][maxi]; ll p[maxi][maxi]; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, m; cin>>n>>m; for(int i=1;i<=n; i++){ for(int j=1; j<=m; j++){ cin>>a[i][j]; p[i][j]=(a[i][j]+p[i-1][j]+p[i][j-1])-p[i-1][j-1]; } } ll ans=-1e9; ll aux=0; for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ aux=-1e9; for(int i1=i;i1<=n; i1++){ for(int j1=j; j1<=m; j1++){ aux=max(aux, p[i1][j1]-p[i-1][j1]-p[i1][j-1]+p[i-1][j-1]); } } ans = max(ans, aux); } } cout<<ans<<endl; }