백준 31496번: 자작나무가 없소~ #Python

ColorlessDia·2025년 12월 29일

algorithm/baekjoon

목록 보기
771/836
import sys

input = sys.stdin.readline

N, S = input().rstrip().split()
N = int(N)

total_count = 0

for _ in range(N):
    item, count = input().rstrip().split()
    item_set = set(item.split('_'))
    count = int(count)

    if S in item_set:
        total_count += count

print(total_count)

0개의 댓글