잃어버린 괄호

last update: 2021.09.08.WED

1541 잃어버린 괄호, Silver 2

Memory 29200KB, Time 72ms


import sys
oper = sys.stdin.readline().strip().split("-")
result = []
answer = 0

for i in oper:
    result.append(list(map(int, i.split("+"))))

for i in range(len(result)):
    if i == 0:
        answer += sum(result[i])
    else:
        answer -= sum(result[i])
print(answer)