다이어트

han.user();·2023년 4월 10일
0

구름

목록 보기
14/20
post-thumbnail

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");

        int W = Integer.parseInt(input[0]);
        int N = Integer.parseInt(input[1]);

        for (int i = 0; i < N; i++) {
            String[] dayInput = br.readLine().split(" ");

            int c = Integer.parseInt(dayInput[0]);
            int e = Integer.parseInt(dayInput[1]);

            if (c > e && W <= 80) {
                W++;
            } else if (c < e && W >= 10) {
                W--;
            } else if (c == e) {
                continue;
            }
        }
        System.out.println(W);
    }
}
profile
I'm still hungry.

0개의 댓글