• 문제 링크
11597번: Excellence
The World Coding Federation is setting up a huge online programming tournament of teams comprised of pairs of programmers. Judge David is in charge of putting teams together from the Southeastern delegation. Every student must be placed on exactly one team
www.acmicpc.net
• 풀이 코드
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 n = read();
int[] arr = new int[n];
for (int i = 0; i < n; i++) arr[i] = read();
Arrays.sort(arr);
int min = Integer.MAX_VALUE;
for (int i = 0; i < n; i++) min = Math.min(min, arr[i] + arr[n - i - 1]);
bw.write(String.valueOf(min));
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' 카테고리의 다른 글
[백준] 2908 상수 - Implementation / Java (0) | 2024.04.17 |
---|---|
[백준] 1157 단어 공부 - Implementation / Java (0) | 2024.04.16 |
[백준] 27851 Watching Mooloo - Greedy / Java (0) | 2024.04.14 |
[백준] 21146 Rating Problems - Greedy / Java (0) | 2024.04.13 |
[백준] 15001 Frog Leaps - Greedy / Java (0) | 2024.04.12 |
댓글