• 문제 링크
https://www.acmicpc.net/problem/5523
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringBuilder sb = new StringBuilder();
int n = read(), a = 0, b = 0;
while (n-- > 0) {
int i = read() - read();
if (i > 0) a++;
else if (i < 0) b++;
}
bw.write(sb.append(a).append(' ').append(b).toString());
bw.flush();
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 33540 Helping Out - Data Structure / Java (0) | 2025.03.15 |
---|---|
[백준] 10709 기상캐스터 - Implementation / Java (0) | 2025.03.14 |
[백준] 5613 계산기 프로그램 - Implementation / Java (0) | 2025.03.12 |
[백준] 2774 아름다운 수 - Implementation / Java (0) | 2025.03.11 |
[백준] 3062 수 뒤집기 - Implementation / Java (0) | 2025.03.10 |
댓글