• 문제 링크
https://www.acmicpc.net/problem/5576
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int[] arr = new int[10];
for (int i = 0; i < 10; i++) arr[i] = read();
int w = sum(arr);
for (int i = 0; i < 10; i++) arr[i] = read();
bw.write(w + " " + sum(arr));
bw.flush();
}
private static int sum(int[] arr) {
Arrays.sort(arr);
return arr[9] + arr[8] + arr[7];
}
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' 카테고리의 다른 글
[백준] 2789 유학 금지 - Implementation / Java (0) | 2024.12.09 |
---|---|
[백준] 4458 첫 글자를 대문자로 - Implementation / Java (0) | 2024.12.08 |
[백준] 1236 성 지키기 - Implementation / Java (0) | 2024.12.06 |
[백준] 32371 샷건 - Brute Force / Java (0) | 2024.12.05 |
[백준] 15449 Art - Brute Force / Java (0) | 2024.12.04 |
댓글