From 55dc55d29509584720feb6163a400e5fd71cfe61 Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Thu, 26 Feb 2026 15:16:43 +0900 Subject: [PATCH] =?UTF-8?q?[20260226]=20BOJ=20/=20G5=20/=20=EB=91=90?= =?UTF-8?q?=EA=B0=9C=EC=9D=98=20=ED=83=91=20/=20=EC=9D=B4=EC=9D=B8?= =?UTF-8?q?=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\352\260\234\354\235\230 \355\203\221.md" | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 "LiiNi-coder/202602/26 BOJ \353\221\220\352\260\234\354\235\230 \355\203\221.md" diff --git "a/LiiNi-coder/202602/26 BOJ \353\221\220\352\260\234\354\235\230 \355\203\221.md" "b/LiiNi-coder/202602/26 BOJ \353\221\220\352\260\234\354\235\230 \355\203\221.md" new file mode 100644 index 00000000..4582cf73 --- /dev/null +++ "b/LiiNi-coder/202602/26 BOJ \353\221\220\352\260\234\354\235\230 \355\203\221.md" @@ -0,0 +1,48 @@ +```java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class Main { + static long[] Prefix; + static long Total; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine().trim()); + long[] dist = new long[N]; + for(int i = 0; i < N; i++) { + dist[i] = Long.parseLong(br.readLine()); + } + + //원형 -> 배열을 2배 + Prefix = new long[2*N + 1]; + for(int i = 0; i < 2 * N; i++) { + Prefix[i + 1] = Prefix[i] + dist[i % N]; + } + Total = Prefix[N]; + long answer = 0; + for(int i = 0; i < N; i++) { + int l = i; + int r = i + N; + while(l + 1 < r) { + int mid = (l+r) / 2; + if(check(i, mid) == check(i, l)) { + l = mid; + }else { + r = mid; + } + } + long clockwise = Prefix[l] - Prefix[i]; + answer = Math.max(answer, clockwise); + } + + System.out.println(answer); + } + + static boolean check(int i, int mid) { + return (Prefix[mid] - Prefix[i]<= Total/2); + } +} + +```