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

Envío 588

Problema 0xf2 - Partir un arreglo grande en 2

  • Autor: d4vsanchez
  • Fecha: 2020-09-08 14:01:12 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.02 s 3 KBi
#2
Correcto
0.023 s 3 KBi
#3
Correcto
0.029 s 3 KBi
#4
Correcto
0.029 s 4 KBi
#5
Correcto
0.027 s 3 KBi
#6
Correcto
0.025 s 4 KBi
#7
Correcto
0.034 s 3 KBi
#8
Correcto
0.029 s 3 KBi
#9
Correcto
0.026 s 3 KBi
#10
Correcto
0.023 s 3 KBi
#11
Correcto
0.027 s 3 KBi
#12
Correcto
0.026 s 3 KBi
#13
Correcto
0.025 s 3 KBi
#14
Tiempo límite excedido
0.308 s 33 KBi
#15
Tiempo límite excedido
1.016 s 13 KBi
#16
Tiempo límite excedido
1.023 s 28 KBi
#17
Tiempo límite excedido
0.359 s 28 KBi
#18
Correcto
0.19 s 28 KBi
#19
Tiempo límite excedido
0.463 s 29 KBi
#20
Tiempo límite excedido
0.316 s 58 KBi
Puntos totales: 70 / 100

Código

import math

n = int(input())
numbers = [int(number) for number in input().split()]

assert len(numbers) == n

split_position = math.inf
for i in range(1, n + 1):
    left_sum = sum(numbers[:i])
    right_sum = sum(numbers[i:])
    if right_sum < 0 and left_sum > 0 and i < split_position:
        split_position = i
        break

if split_position != math.inf:
    print(split_position)
else:
    print("Impossible")