문제

https://www.acmicpc.net/problem/25304


문제 풀이

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //총 금액
        int X = sc.nextInt();
        //영수증에 적힌 구매한 물건의 종류의 수
        int N = sc.nextInt();

        int sum=0;

        for (int i = 0; i < N; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            sum += (a*b);
        }

        if(sum==X) System.out.println("Yes");
        else System.out.println("No");
    }
}

카테고리:

업데이트:

댓글남기기