CS Academy Round #38: A. Shoe Pairs
implementation
collections.defaultdict
は便利。
#!/usr/bin/env python3
import collections
n = int(input())
shoes = collections.defaultdict(lambda: { 'L': 0, 'R': 0 })
for _ in range(n):
a, b = input().split()
shoes[a][b] += 1
result = 0
for cnt in shoes.values():
result += min(cnt['L'], cnt['R'])
print(result)