Playground/자바문제집

[백준] 25304번

미숫가루설탕많이 2023. 1. 8. 11:41
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);

        //25304번
        int totalPrice, count;
        totalPrice = sc.nextInt();  // 총 금액
        count = sc.nextInt();   // 구매한 물건의 종류 수

        int product[][] = new int[count][2];    // 이중배열 선언
        int comp = 0;   // 금액 비교

        for (int i = 0; i < product.length; i++) {
            product[i][0] = sc.nextInt(); // 상품 가격
            product[i][1] = sc.nextInt(); // 상품 개수
            comp += product[i][0] * product[i][1]; // 총 금액과 맞는지 비교
        }

        if (totalPrice == comp) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        
    }
}

'Playground > 자바문제집' 카테고리의 다른 글

[백준] 11021번  (0) 2023.01.19
[백준] 1152번  (0) 2023.01.19
[백준] 8393번  (0) 2022.12.25
[백준] 10950번  (0) 2022.12.25
[백준] 2525번  (0) 2022.12.25