From 3034567a106cc3a677de59430f0deae9ac6af961 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Sat, 9 Aug 2025 10:44:35 +0900 Subject: [PATCH] =?UTF-8?q?[20250811]=20BOJ=20/=20G5=20/=20=EC=BD=98?= =?UTF-8?q?=EC=84=BC=ED=8A=B8=20/=20=EA=B9=80=EC=88=98=EC=97=B0?= 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" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "suyeun84/202508/11 BOJ G5 \354\275\230\354\204\274\355\212\270.md" diff --git "a/suyeun84/202508/11 BOJ G5 \354\275\230\354\204\274\355\212\270.md" "b/suyeun84/202508/11 BOJ G5 \354\275\230\354\204\274\355\212\270.md" new file mode 100644 index 00000000..30809124 --- /dev/null +++ "b/suyeun84/202508/11 BOJ G5 \354\275\230\354\204\274\355\212\270.md" @@ -0,0 +1,34 @@ +```java +import java.io.*; +import java.util.*; + +public class boj23843 { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringTokenizer st; + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + + public static void main(String[] args) throws Exception { + nextLine(); + int N = nextInt(); + int M = nextInt(); + int answer = 0; + Integer[] t = new Integer[N]; + PriorityQueue pq = new PriorityQueue<>(); + nextLine(); + for (int i = 0; i < N; i++) t[i] = nextInt(); + Arrays.sort(t); + for (int i = 0; i < M; i++) { + pq.add(0); + } + for (int i = N - 1; i >= 0; i--) { + int tmp = pq.poll() + t[i]; + pq.add(tmp); + } + while (!pq.isEmpty()) { + answer = Math.max(pq.poll(), answer); + } + System.out.println(answer); + } +} +```