Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.027 s | 3 KBi |
#2 |
Correcto
|
0.029 s | 3 KBi |
#3 |
Correcto
|
0.022 s | 3 KBi |
#4 |
Correcto
|
0.024 s | 3 KBi |
#5 |
Correcto
|
0.026 s | 3 KBi |
#6 |
Correcto
|
0.027 s | 3 KBi |
#7 |
Correcto
|
0.039 s | 7 KBi |
#8 |
Correcto
|
0.032 s | 3 KBi |
#9 |
Correcto
|
0.04 s | 3 KBi |
#10 |
Correcto
|
0.027 s | 5 KBi |
#11 |
Correcto
|
0.024 s | 3 KBi |
#12 |
Correcto
|
0.038 s | 3 KBi |
#13 |
Correcto
|
0.026 s | 5 KBi |
#14 |
Tiempo límite excedido
|
1.043 s | 33 KBi |
#15 |
Tiempo límite excedido
|
0.887 s | 12 KBi |
#16 |
Tiempo límite excedido
|
0.979 s | 32 KBi |
#17 |
Tiempo límite excedido
|
1.032 s | 28 KBi |
#18 |
Tiempo límite excedido
|
0.427 s | 28 KBi |
#19 |
Tiempo límite excedido
|
0.491 s | 28 KBi |
#20 |
Tiempo límite excedido
|
1.044 s | 57 KBi |
import math n = int(input()) numbers = [int(number) for number in input().split()] assert len(numbers) == n right_side_sum = [0] left_side_sum = [0] for i in range(1, n): previous_left = left_side_sum[i-1] previous_right = right_side_sum[0] left_side_sum.append(previous_left + numbers[i - 1]) right_side_sum.insert(0, previous_right + numbers[n - i]) split_number = -1 for i in range(1, n): if right_side_sum[i - 1] < 0 and left_side_sum[i] > 0: split_number = i break if right_side_sum[n - (i + 1)] < 0 and left_side_sum[n - i] > 0: split_number = n - i if split_number == -1: print("Impossible") else: print(split_number)