From d17071eacc23a821d106d60c318c8f8e955b4250 Mon Sep 17 00:00:00 2001 From: zinnnn37 <102711874+zinnnn37@users.noreply.github.com> Date: Mon, 26 Jan 2026 22:58:18 +0900 Subject: [PATCH] =?UTF-8?q?[20260126]=20BOJ=20/=20G5=20/=20=EA=B8=B0?= =?UTF-8?q?=ED=83=80=20=EB=A0=88=EC=8A=A8=20/=20=EA=B9=80=EB=AF=BC?= =?UTF-8?q?=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\355\203\200 \353\240\210\354\212\250.md" | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 "zinnnn37/202601/26 BOJ G5 \352\270\260\355\203\200 \353\240\210\354\212\250.md" diff --git "a/zinnnn37/202601/26 BOJ G5 \352\270\260\355\203\200 \353\240\210\354\212\250.md" "b/zinnnn37/202601/26 BOJ G5 \352\270\260\355\203\200 \353\240\210\354\212\250.md" new file mode 100644 index 00000000..dcd677aa --- /dev/null +++ "b/zinnnn37/202601/26 BOJ G5 \352\270\260\355\203\200 \353\240\210\354\212\250.md" @@ -0,0 +1,71 @@ +```java +import java.io.*; +import java.util.StringTokenizer; + +public class BJ_2343_기타_레슨 { + + private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + private static StringTokenizer st; + + private static int N, M, left, right, ans; + private static int[] lessons; + + public static void main(String[] args) throws IOException { + init(); + sol(); + } + + private static void init() throws IOException { + st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + + left = right = 0; + ans = Integer.MAX_VALUE; + lessons = new int[N]; + + st = new StringTokenizer(br.readLine()); + for (int i = 0; i < N; i++) { + lessons[i] = Integer.parseInt(st.nextToken()); + left = Math.max(left, lessons[i]); + right += lessons[i]; + } + } + + private static void sol() throws IOException { + while (left <= right) { + int mid = left + (right - left) / 2; + + if (isRecordable(mid)) { + ans = Math.min(ans, mid); + right = mid - 1; + } else { + left = mid + 1; + } + } + + bw.write(ans + ""); + bw.flush(); + bw.close(); + br.close(); + } + + private static boolean isRecordable(int mid) { + int cnt = 1; + int sum = 0; + + for (int lesson : lessons) { + if (sum + lesson <= mid) { + sum += lesson; + } else { + cnt++; + sum = lesson; + } + } + + return cnt <= M; + } + +} +```