https://www.acmicpc.net/problem/25304
25304번: 영수증
준원이는 저번 주에 살면서 처음으로 코스트코를 가 봤다. 정말 멋졌다. 그런데, 몇 개 담지도 않았는데 수상하게 높은 금액이 나오는 것이다! 준원이는 영수증을 보면서 정확하게 계산된 것
www.acmicpc.net
풀이
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int total = sc.nextInt();
int count = sc.nextInt();
for(int i = 0; i < count; i++) {
int price = sc.nextInt();
int num = sc.nextInt();
total -= (price * num);
}
if(total == 0) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}
'Algorithm > Baekjoon' 카테고리의 다른 글
[백준] 25314번 : 코딩은 체육과목 입니다 - Java (0) | 2023.07.19 |
---|---|
[백준] 11382번 : 꼬마 정민 - Java (0) | 2023.07.18 |
[백준] 1436번 : 영화감독 숌 - Java (0) | 2022.05.10 |
[백준] 25083번 : 새싹 - Java (0) | 2022.05.10 |
[백준] 7568번 : 덩치 - Java (0) | 2022.04.26 |
댓글