From b6af47723da63945d8358830a9a0ff1a500ba8a2 Mon Sep 17 00:00:00 2001 From: Ukj0ng <90972240+Ukj0ng@users.noreply.github.com> Date: Mon, 13 Oct 2025 12:47:20 +0900 Subject: [PATCH] =?UTF-8?q?[20251013]=20BOJ=20/=20G5=20/=20=EB=91=90=20?= =?UTF-8?q?=EA=B0=9C=EC=9D=98=20=ED=83=91=20/=20=ED=95=9C=EC=A2=85?= =?UTF-8?q?=EC=9A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... \352\260\234\354\235\230 \355\203\221.md" | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 "Ukj0ng/202510/13 BOJ G5 \353\221\220 \352\260\234\354\235\230 \355\203\221.md" diff --git "a/Ukj0ng/202510/13 BOJ G5 \353\221\220 \352\260\234\354\235\230 \355\203\221.md" "b/Ukj0ng/202510/13 BOJ G5 \353\221\220 \352\260\234\354\235\230 \355\203\221.md" new file mode 100644 index 00000000..16e2bd66 --- /dev/null +++ "b/Ukj0ng/202510/13 BOJ G5 \353\221\220 \352\260\234\354\235\230 \355\203\221.md" @@ -0,0 +1,48 @@ +``` +import java.io.*; +import java.util.*; + +public class Main { + private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + private static int[] dist; + private static int N, sum, answer; + public static void main(String[] args) throws IOException { + init(); + + bw.write(answer + "\n"); + bw.flush(); + bw.close(); + br.close(); + } + + private static void init() throws IOException { + N = Integer.parseInt(br.readLine()); + sum = 0; + answer = 0; + + dist = new int[N]; + + for (int i = 0; i < N; i++) { + dist[i] = Integer.parseInt(br.readLine()); + sum += dist[i]; + } + + int left = 0; + int right = 1; + int val = dist[right-1]; + + while (left < N) { + answer = Math.max(answer, Math.min(val, sum-val)); + + if (val < sum - val) { + val += dist[right % N]; + right++; + } else { + val -= dist[left]; + left++; + } + } + } +} +```