TOPIC

WRONG 35% - Python

David Holanda asked 10 months ago

onde está o erro?

while True:
    try:
        n = int(input())
        soma = 0
        lista = list(map(int, input().split()))
        valor = []
        for i in range(n):
            valor.insert(i, lista[i])
        metade = int(sum(valor) / 2)
        if sum(valor) % 2 != 0:
            metade += 1
        for i, j in enumerate(valor):
            if soma + valor[i] > metade:
                break
            soma += j
        print(metade - soma)

    except EOFError:
        break

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.