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

Envío 4753

Problema 0xcf - Mirando al horizonte

  • Autor: Ikerlb
  • Fecha: 2021-08-13 05:40:31 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 14, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 9, in max_subarray_sum
    return " ".join(res)
TypeError: can only join an iterable
0.029 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 14, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 9, in max_subarray_sum
    return " ".join(res)
TypeError: can only join an iterable
0.021 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 14, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 9, in max_subarray_sum
    return " ".join(res)
TypeError: can only join an iterable
0.023 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 14, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 9, in max_subarray_sum
    return " ".join(res)
TypeError: can only join an iterable
0.02 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 14, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 9, in max_subarray_sum
    return " ".join(res)
TypeError: can only join an iterable
0.027 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 14, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 9, in max_subarray_sum
    return " ".join(res)
TypeError: can only join an iterable
0.022 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 14, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 9, in max_subarray_sum
    return " ".join(res)
TypeError: can only join an iterable
0.026 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 14, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 9, in max_subarray_sum
    return " ".join(res)
TypeError: can only join an iterable
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 14, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 9, in max_subarray_sum
    return " ".join(res)
TypeError: can only join an iterable
0.023 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 14, in <module>
    print(max_subarray_sum(arr))
  File "script.py", line 9, in max_subarray_sum
    return " ".join(res)
TypeError: can only join an iterable
0.03 s 3 KBi
Puntos totales: 0 / 100

Código

import math

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

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