본문 바로가기
Beakjoon&프로그래머스/Java

[백준/Java] 34302번 Win Streak

by 현장 2025. 10. 13.

-Code

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class BOJ34302 {
    public static void main(String[] args) throws IOException {
        BufferedReader br =
                new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int n = Integer.parseInt(st.nextToken());
        int res = 0;
        int cnt = 0;
        // 입력마다 팀 점수 비교
        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(br.readLine());
            int s = Integer.parseInt(st.nextToken());
            int t = Integer.parseInt(st.nextToken());

            if (s > t) {
                cnt++;
            } else {
                res = Math.max(res, cnt);
                cnt = 0;
            }
        }
        // 마지막 경기가 끝난 이후 계산
        res = Math.max(res, cnt);
        System.out.println(res);
    }
}