From 09b81bc6667a9782be2213d07b6436ca03007ca9 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Thu, 12 Jun 2025 03:39:40 +0900 Subject: [PATCH] =?UTF-8?q?[20250612]=20BOJ=20/=20G3=20/=20=EC=84=B8=20?= =?UTF-8?q?=EC=9A=A9=EC=95=A1=20/=20=EA=B9=80=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... \354\204\270 \354\232\251\354\225\241.md" | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 "suyeun84/202506/12 BOJ G3 \354\204\270 \354\232\251\354\225\241.md" diff --git "a/suyeun84/202506/12 BOJ G3 \354\204\270 \354\232\251\354\225\241.md" "b/suyeun84/202506/12 BOJ G3 \354\204\270 \354\232\251\354\225\241.md" new file mode 100644 index 00000000..dadbcfbf --- /dev/null +++ "b/suyeun84/202506/12 BOJ G3 \354\204\270 \354\232\251\354\225\241.md" @@ -0,0 +1,45 @@ +```java +import java.io.*; +import java.util.*; + +public class boj2473 { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringTokenizer st; + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + + public static void main(String[] args) throws Exception { + nextLine(); + int N = Integer.parseInt(st.nextToken()); + long[] num = new long[N]; + long answer = Long.MAX_VALUE; + long[] res = new long[3]; + nextLine(); + for(int i = 0; i < N; i++) { + num[i] = Long.parseLong(st.nextToken()); + } + Arrays.sort(num); + + for (int i = 0; i < N; i++) { + int start = i+1; + int end = N-1; + while (start < end) { + long temp = num[i] + num[start] + num[end]; + if (Math.abs(temp) < answer) { + res[0] = num[i]; + res[1] = num[start]; + res[2] = num[end]; + answer = Math.abs(temp); + } + if (temp > 0) end--; + else if (temp < 0) start++; + else { + System.out.println(res[0]+" "+res[1]+" "+res[2]); + return; + } + } + } + System.out.println(res[0]+" "+res[1]+" "+res[2]); + } +} +```