ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 백준 25304 JAVA
    ETC/Algorithm 2023. 5. 19. 23:19
    import java.io.*;
    import java.util.StringTokenizer;
    
    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 sum = 0;
            for (int i = 0; i < n; i++) {
                StringTokenizer st = new StringTokenizer(br.readLine(), " ");
                sum += Integer.parseInt(st.nextToken()) * Integer.parseInt(st.nextToken());
            }
    
            if (sum == x) {
                bw.write("Yes");
            } else {
                bw.write("No");
            }
            bw.flush();
        }
    }

    댓글

Designed by black7375.