def solution(max_weight, specs, names):
spec_dict = dict() # (물건이름 : 무게)를 담는 딕셔너리
for spec in specs:
s_name, s_weight = spec
spec_dict[s_name] = int(s_weight)
total = 0 # 트럭 하나에 들어가는 물건들의 무게합
cnt = 1
for name in names:
total += spec_dict[name]
if total > max_weight:
cnt += 1 # 트럭 하나가 더 필요함
total = spec_dict[name]
return cnt