[백준/Java] 25304 : 영수증

SEOP·2023년 5월 11일
0

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int X = Integer.parseInt(br.readLine());
        int N = Integer.parseInt(br.readLine());
        int result = 0;

        List<Map<String,Integer>> list = new ArrayList<>();

        for(int i = 0 ; i < N ; i++){
            String[] STR1 =br.readLine().split(" ");
            Map<String,Integer> map = new HashMap<>();
            map.put("price",Integer.parseInt(STR1[0]));
            map.put("Num",Integer.parseInt(STR1[1]));
            list.add(map);
        }

        for (int j = 0 ; j < list.size() ; j++){
            result += list.get(j).get("price") * list.get(j).get("Num");
        }

        if(X == result){
            bw.write("Yes");
        } else{
            bw.write("No");
        }

        bw.flush();
        bw.close();
    }
}
profile
응애 나 애기 개발자

0개의 댓글