#25304
#include <iostream>
#include <vector>
using namespace std;
int main() {
//총금액
int given_total;
cin >> given_total;
//물건 종류 개수
int item_count;
cin >> item_count;
//계산에 필요한 인자
int calculated_total = 0;
int each_price=0;
int each_count=0;
for (int i = 0;i < item_count;i++) {
cin >> each_price >> each_count;
calculated_total += each_price * each_count;
}
if (given_total == calculated_total) {
cout << "Yes";
}
else cout << "No";
}
처음엔 벡터를 사용하여 모든 데이터를 저장하려 했으나,
데이터는 그 곱을 총 계산 가격에 더한 이후에는 필요가 없으므로 동일한 변수를 반복하여 재사용하였다.
'Coding > Step By Step' 카테고리의 다른 글
Baekjoon Training / Algorithm-완전탐색 / #17614 (0) | 2023.03.12 |
---|---|
Baekjoon Training / Algorithm-완전탐색 / #3040 (0) | 2023.03.12 |
Baekjoon Training / #5597 / ing (0) | 2023.02.11 |
Baekjoon Training / Algorithm(math) / #11653 / ing (1) | 2023.02.10 |
Baekjoon Training / recursion(재귀) / #25501 / ing (0) | 2023.02.09 |