Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 3 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 9 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.006 s | 1 KBi |
#8 |
Correcto
|
0.006 s | 3 KBi |
#9 |
Correcto
|
0.006 s | 13 KBi |
#10 |
Correcto
|
0.006 s | 8 KBi |
#11 |
Correcto
|
0.007 s | 1 KBi |
#12 |
Correcto
|
0.007 s | 1 KBi |
#13 |
Correcto
|
0.008 s | 17 KBi |
#14 |
Correcto
|
0.007 s | 61 KBi |
#15 |
Correcto
|
0.006 s | 1 KBi |
#16 |
Correcto
|
0.007 s | 1 KBi |
#17 |
Correcto
|
0.007 s | 1 KBi |
#18 |
Correcto
|
0.006 s | 1 KBi |
#include<bits/stdc++.h> using namespace std; int max1d(vector<int> input){ int total_max = input[0]; int current_max = input[0]; for(int i=1; i< input.size(); i++){ current_max = max(current_max, 0) + input[i]; total_max = max(current_max, total_max); } return total_max; } int main() { int r,c; int answer = INT_MIN; cin >>r >> c; int matrix[r][c]; for(int row=0;row<r; row++){ for(int col=0;col<c; col++){ cin >> matrix[row][col]; } } for(int col1=0;col1<c;col1++){ vector<int> input(r, 0); for(int col2=col1;col2<c;col2++){ for(int row=0; row<r; row++){ input[row]+=matrix[row][col2]; } answer = max(answer, max1d(input)); } } cout << answer << endl; }