Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.022 s | 3 KBi |
#2 |
Correcto
|
0.023 s | 3 KBi |
#3 |
Correcto
|
0.02 s | 3 KBi |
#4 |
Correcto
|
0.022 s | 3 KBi |
#5 |
Correcto
|
0.021 s | 3 KBi |
#6 |
Correcto
|
0.028 s | 3 KBi |
#7 |
Correcto
|
0.022 s | 3 KBi |
#8 |
Correcto
|
0.058 s | 3 KBi |
#9 |
Correcto
|
0.065 s | 3 KBi |
#10 |
Correcto
|
0.06 s | 3 KBi |
#11 |
Correcto
|
0.055 s | 3 KBi |
#12 |
Correcto
|
0.07 s | 3 KBi |
#13 |
Correcto
|
0.075 s | 3 KBi |
#14 |
Correcto
|
0.062 s | 3 KBi |
#15 |
Correcto
|
0.062 s | 3 KBi |
#16 |
Correcto
|
0.071 s | 3 KBi |
#17 |
Correcto
|
0.055 s | 3 KBi |
#18 |
Correcto
|
0.056 s | 3 KBi |
def kadane(arr): max_sum = last_sum = arr[0] for i in arr[1:]: last_sum = max(last_sum + i, i) max_sum = max(max_sum, last_sum) return max_sum def get_max(m, r, c): max_sum = m[0][0] for i in range(r): col_values = [0] * c for j in m[i:]: for q in range(c): col_values[q] = col_values[q] + j[q] max_sub = kadane(col_values) max_sum = max(max_sum, max_sub) return max_sum [r, c] = map(int, input().split()) m = [] for i in range(0, r): m.append(list(map(int, input().split(" ")))) print(get_max(m, r, c))