
-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);
}
}'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
| [백준/Java] 34310번 No Stragglers (0) | 2025.10.14 |
|---|---|
| [프로그래머스/Java] 2 x n 타일링 (0) | 2025.10.13 |
| [백준/Java] 24795번 Saving Princess Peach (0) | 2025.10.12 |
| [백준/Java] 11724번 연결 요소의 개수 (0) | 2025.10.01 |
| [백준/Java] 2750번 소트인사이드 (0) | 2025.09.26 |