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

Envío 595

Problema 0xf2 - Partir un arreglo grande en 2

  • Autor: d4vsanchez
  • Fecha: 2020-09-08 21:12:40 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.026 s 3 KBi
#2
Correcto
0.024 s 3 KBi
#3
Correcto
0.028 s 4 KBi
#4
Correcto
0.028 s 4 KBi
#5
Correcto
0.022 s 3 KBi
#6
Correcto
0.031 s 4 KBi
#7
Correcto
0.027 s 3 KBi
#8
Correcto
0.024 s 3 KBi
#9
Correcto
0.028 s 3 KBi
#10
Correcto
0.03 s 4 KBi
#11
Correcto
0.027 s 4 KBi
#12
Correcto
0.031 s 4 KBi
#13
Correcto
0.029 s 3 KBi
#14
Tiempo límite excedido
0.594 s 32 KBi
#15
Tiempo límite excedido
0.422 s 12 KBi
#16
Tiempo límite excedido
0.375 s 29 KBi
#17
Tiempo límite excedido
1.018 s 30 KBi
#18
Correcto
0.178 s 33 KBi
#19
Tiempo límite excedido
0.682 s 29 KBi
#20
Tiempo límite excedido
0.704 s 59 KBi
Puntos totales: 70 / 100

Código

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

assert len(numbers) == n

split_position = -1
i = 1
j = n - 1
while i <= j:
    left_sum = sum(numbers[:i])
    right_sum = sum(numbers[i:])
    if right_sum < 0 and left_sum > 0 and i:
        split_position = i
        break

    left_sum = sum(numbers[:j])
    right_sum = sum(numbers[j:])
    if right_sum < 0 and left_sum > 0:
        split_position = j

    i = i + 1
    j = j - 1

if split_position != -1:
    print(split_position)
else:
    print("Impossible")