█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 4750

Problema 0x94 - Subarreglo de máxima suma

  • Autor: Ikerlb
  • Fecha: 2021-08-13 05:29:51 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.022 s 3 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.025 s 3 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.02 s 3 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.029 s 3 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.032 s 3 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.027 s 3 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.022 s 3 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.02 s 3 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.021 s 3 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.022 s 3 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.021 s 3 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.023 s 3 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.023 s 3 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.021 s 3 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.022 s 3 KBi
#16
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.02 s 3 KBi
#17
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.049 s 12 KBi
#18
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.057 s 12 KBi
#19
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.049 s 12 KBi
#20
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.049 s 12 KBi
#21
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.046 s 12 KBi
#22
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.05 s 12 KBi
#23
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.044 s 10 KBi
#24
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 12, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 3, in max_subarray_sum
    res = -math.inf
NameError: name 'math' is not defined
0.045 s 10 KBi
Puntos totales: 0 / 100

Código

def max_subarray_sum(arr):
    cur = 0
    res = -math.inf
    for n in arr:
        cur = max(cur + n, n)
        res = max(res, cur)
    return res

if __name__ == "__main__":
    N = int(input())
    arr = list(map(int, input().split(" ")))
    print(max_subarray_sum(arr))