본문 바로가기

IT개발자/백준_Algorithm

백준 25304번 영수증 JAVA(자바) 문제풀이

728x90
반응형
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int total = scan.nextInt();
		int count = scan.nextInt();
		
		int temp = 0;
		
		for(int i = 0; i< count; i++) {
			int price = scan.nextInt();
			int num = scan.nextInt();
			
			temp += price*num;
			
		}
		
		if((total-temp) == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}
728x90
반응형