From b547625160a84a17e8682015ccc0da8dc49e9697 Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Tue, 22 Jul 2025 22:38:08 +0900 Subject: [PATCH] =?UTF-8?q?[20250722]=20BOJ=20/=20G5=20/=20=EB=91=90=20?= =?UTF-8?q?=EA=B0=9C=EC=9D=98=20=ED=83=91=20/=20=EC=9D=B4=EA=B0=95?= =?UTF-8?q?=ED=98=84?= 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" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "lkhyun/202507/22 BOJ G5 \353\221\220 \352\260\234\354\235\230 \355\203\221.md" diff --git "a/lkhyun/202507/22 BOJ G5 \353\221\220 \352\260\234\354\235\230 \355\203\221.md" "b/lkhyun/202507/22 BOJ G5 \353\221\220 \352\260\234\354\235\230 \355\203\221.md" new file mode 100644 index 00000000..ffbfcf71 --- /dev/null +++ "b/lkhyun/202507/22 BOJ G5 \353\221\220 \352\260\234\354\235\230 \355\203\221.md" @@ -0,0 +1,44 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + + public static void main(String[] args) throws Exception { + int N = Integer.parseInt(br.readLine()); + int[] point = new int[N]; + int totalSum = 0; + + for (int i = 0; i < N; i++) { + point[i] = Integer.parseInt(br.readLine()); + totalSum += point[i]; + } + + int left = 0; + int right = 1; + int clockwiseSum = point[0]; + int max = 0; + + while (left < N) { + int counterClockwiseSum = totalSum - clockwiseSum; + int distance = Math.min(clockwiseSum, counterClockwiseSum); + max = Math.max(max, distance); + + if (clockwiseSum < counterClockwiseSum) { + clockwiseSum += point[right]; + right = (right + 1) % N; + } else { + clockwiseSum -= point[left]; + left++; + } + + if (left == right) break; + } + + bw.write(Integer.toString(max)); + bw.close(); + } +} +```