From 86a7a9c66acc21d5d13ef95479681f336924a950 Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Mon, 3 Nov 2025 23:53:15 +0900 Subject: [PATCH] =?UTF-8?q?[20251103]=20BOJ=20/=20G5=20/=20=EC=BD=98?= =?UTF-8?q?=EC=84=BC=ED=8A=B8=20/=20=EC=84=A4=EC=A7=84=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5 \354\275\230\354\204\274\355\212\270.md" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "Seol-JY/202511/3 BOJ G5 \354\275\230\354\204\274\355\212\270.md" diff --git "a/Seol-JY/202511/3 BOJ G5 \354\275\230\354\204\274\355\212\270.md" "b/Seol-JY/202511/3 BOJ G5 \354\275\230\354\204\274\355\212\270.md" new file mode 100644 index 00000000..16b74c7e --- /dev/null +++ "b/Seol-JY/202511/3 BOJ G5 \354\275\230\354\204\274\355\212\270.md" @@ -0,0 +1,38 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + String[] firstLine = br.readLine().split(" "); + int N = Integer.parseInt(firstLine[0]); + int M = Integer.parseInt(firstLine[1]); + + String[] secondLine = br.readLine().split(" "); + Integer[] times = new Integer[N]; + for (int i = 0; i < N; i++) { + times[i] = Integer.parseInt(secondLine[i]); + } + + Arrays.sort(times, (a, b) -> b - a); + + PriorityQueue pq = new PriorityQueue<>(); + for (int i = 0; i < M; i++) { + pq.offer(0L); + } + + for (int time : times) { + long minTime = pq.poll(); + pq.offer(minTime + time); + } + + long result = 0; + while (!pq.isEmpty()) { + result = Math.max(result, pq.poll()); + } + + System.out.println(result); + } +} +```