백준 13650번: Botas perdidas #Python

ColorlessDia·2024년 9월 18일

algorithm/baekjoon

목록 보기
304/807
import sys

while True:
    line = sys.stdin.readline().rstrip()

    if line == '':
        break
    
    boots_count = dict()
    
    N = int(line)

    for _ in range(N):
        M, L = sys.stdin.readline().rstrip().split()

        if M in boots_count:
            
            if L == 'E':
                boots_count[M][0] += 1
            elif L == 'D':
                boots_count[M][1] += 1
        
            continue
        
        if L == 'E':
            boots_count[M] = [1, 0]
        elif L == 'D':
            boots_count[M] = [0, 1]
    
    count = 0

    for left, right in boots_count.values():
        count += min(left, right)
    
    print(count)

0개의 댓글