• 문제 링크
https://www.acmicpc.net/problem/2511
• 풀이 코드
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[] A = new int[10], B = new int[10];
for (int i = 0; i < 10; i++) A[i] = read();
for (int i = 0; i < 10; i++) B[i] = read();
int a = 0, b = 0;
char c = 'D';
for (int i = 0; i < 10; i++) {
if (A[i] > B[i]) {
a += 3;
c = 'A';
} else if (A[i] < B[i]) {
b += 3;
c = 'B';
} else {
a++;
b++;
}
}
bw.write(sb.append(a).append(" ").append(b).append("\n").append(a > b ? "A" : a < b ? "B" : c).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' 카테고리의 다른 글
[백준] 30614 Port Robot - Data Structure / Java (0) | 2025.02.05 |
---|---|
[백준] 14455 Don't Be Last! - Data Structure / Java (0) | 2025.02.04 |
[백준] 5218 알파벳 거리 - Implementation / Java (0) | 2025.02.02 |
[백준] 5586 JOI와 IOI - Implementation / Java (0) | 2025.02.01 |
[백준] 1371 가장 많은 글자 - Implementation / Java (0) | 2025.01.31 |
댓글