반응형
깃 링크 : 바로가기
링크 : 바로가기
1차시도
public class num_25304
{
public static void Main()
{
int total = Convert.ToInt32(Console.ReadLine());
int max = Convert.ToInt32(Console.ReadLine());
int price_total = 0;
for (int i = 0; i < max; i++)
{
string[] input = Console.ReadLine().Split();
int item = int.Parse(input[0]);
int item_count = int.Parse(input[1]);
price_total += item * item_count;
}
Console.WriteLine(total.CompareTo(price_total) == 0 ? "Yes" : "No");
}
}
결과
- for문을 이용해 입력받은 값을 + 해준 후 값이 동일하면 "Yes" 아니면 "No"출력
반응형
'기타 > 코딩테스트 공부' 카테고리의 다른 글
[백준] 빠른 A+B - 15552번 (0) | 2025.05.01 |
---|---|
[백준] 코딩은 체육과목 입니다 - 25314번 (0) | 2025.05.01 |
[백준] 합 - 8393번 (0) | 2025.05.01 |
[백준] A+B - 10950번 (0) | 2025.05.01 |
[백준] 구구단 - 2739번 (0) | 2025.05.01 |