본문 바로가기

1day 1coding/백준 단계별 문제

[백준/Java] 25304번: 영수증

 

반복문을 활용해서 문제풀이에 접근해보자

 

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 int totalAmount = scan.nextInt();
		 int totalCount = scan.nextInt();
		 
		 for (int i = 0; i < totalCount; i++) {
			 int amount = scan.nextInt() * scan.nextInt();
			 totalAmount -= amount;
		 }
		 
		 if (totalAmount == 0) System.out.print("Yes"); 
		 else System.out.print("No"); 
	}
	    
}