백준 34310번: No Stragglers #Python

ColorlessDia·2025년 12월 3일

algorithm/baekjoon

목록 보기
745/807
import sys

input = sys.stdin.readline

N = int(input())

history = dict(zip(['STU', 'FAC', 'VIS'], [0, 0, 0]))

for _ in range(N):
    person_type, direction, count = input().rstrip().split()
    count = int(count)

    if direction == 'IN':
        history[person_type] += count
    elif direction == 'OUT':
        history[person_type] -= count

straggler = sum(history.values())

if not straggler:
    print('NO STRAGGLERS')
else:
    print(straggler)

0개의 댓글