Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.01 s | 3 KBi |
#2 |
Correcto
|
0.019 s | 3 KBi |
#3 |
Correcto
|
0.01 s | 3 KBi |
#4 |
Correcto
|
0.01 s | 3 KBi |
#5 |
Correcto
|
0.01 s | 3 KBi |
#6 |
Correcto
|
0.01 s | 3 KBi |
#7 |
Correcto
|
0.024 s | 5 KBi |
#8 |
Correcto
|
0.011 s | 3 KBi |
#9 |
Correcto
|
0.011 s | 3 KBi |
#10 |
Correcto
|
0.012 s | 3 KBi |
#11 |
Correcto
|
0.011 s | 3 KBi |
#12 |
Correcto
|
0.017 s | 3 KBi |
#13 |
Correcto
|
0.009 s | 3 KBi |
#14 |
Correcto
|
0.015 s | 3 KBi |
#15 |
Correcto
|
0.018 s | 3 KBi |
#16 |
Correcto
|
0.017 s | 3 KBi |
#17 |
Correcto
|
0.264 s | 11 KBi |
#18 |
Correcto
|
0.22 s | 12 KBi |
#19 |
Correcto
|
0.246 s | 12 KBi |
#20 |
Correcto
|
0.282 s | 12 KBi |
#21 |
Correcto
|
0.245 s | 11 KBi |
#22 |
Correcto
|
0.236 s | 12 KBi |
#23 |
Correcto
|
0.235 s | 10 KBi |
#24 |
Correcto
|
0.237 s | 10 KBi |
def findBest(a): n = len(a) if n <= 1: return a[0]; m = n // 2 best = max(findBest(a[:m]), findBest(a[m:])) bsl = a[m-1] sl = a[m-1] for i in range(m-2, -1, -1): sl += a[i] bsl = max(bsl, sl) bsr = a[m] sr = a[m] for i in range(m+1, n): sr += a[i] bsr = max(bsr, sr) return max(best, bsl+bsr) n = int(input()) a = [int(x) for x in input().split()] print(findBest(a))