## 의사코드 ##
# 딕셔너리에 물건의 가격과 개수를 저장해서 총 금액 계산
# dic = {} # 영수증
# for _ in range(n):
# # 물건의 가격과 개수
# a, b = map(int, input().split())
# dic[a] = b
# # 총 금액 계산
# total = 0 # 구매한 물건의 가격과 개수로 계산한 총 금액
# for a, b in dic.items():
# total += a * b
# if x == total:
# print('Yes')
# else:
# print('No')
첫 번째 시도
x = int(input()) # 영수증에 적힌 총 금액
n = int(input()) # 물건의 종류 수
dic = {} # 영수증
for _ in range(n):
# 물건의 가격과 개수
a, b = map(int, input().split())
dic[a] = b
# 총 금액 계산
total = 0 # 구매한 물건의 가격과 개수로 계산한 총 금액
for a, b in dic.items():
total += a * b
if x == total:
print('Yes')
else:
print('No')
-> 틀림
통과한 코드
x = int(input()) # 영수증에 적힌 총 금액
n = int(input()) # 물건의 종류 수
total = 0 # 구매한 물건의 가격과 개수로 계산한 총 금액
for _ in range(n):
# 물건의 가격과 개수
a, b = map(int, input().split())
total += a * b
if x == total:
print('Yes')
else:
print('No')