From d2657316e6f2eb558104a3ec81d0709895fcf857 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Wed, 8 Oct 2025 23:09:00 +0900 Subject: [PATCH] =?UTF-8?q?[20251008]=20PGM=20/=20LV2=20/=20=EC=84=9C?= =?UTF-8?q?=EB=B2=84=20=EC=A6=9D=EC=84=A4=20=ED=9A=9F=EC=88=98=20/=20?= =?UTF-8?q?=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\204\244 \355\232\237\354\210\230.md" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "suyeun84/202510/08 PGM LV2 \354\204\234\353\262\204 \354\246\235\354\204\244 \355\232\237\354\210\230.md" diff --git "a/suyeun84/202510/08 PGM LV2 \354\204\234\353\262\204 \354\246\235\354\204\244 \355\232\237\354\210\230.md" "b/suyeun84/202510/08 PGM LV2 \354\204\234\353\262\204 \354\246\235\354\204\244 \355\232\237\354\210\230.md" new file mode 100644 index 00000000..d78436a1 --- /dev/null +++ "b/suyeun84/202510/08 PGM LV2 \354\204\234\353\262\204 \354\246\235\354\204\244 \355\232\237\354\210\230.md" @@ -0,0 +1,24 @@ +```java +import java.util.*; +class Solution { + public int solution(int[] players, int m, int k) { + PriorityQueue pq = new PriorityQueue<>((o1,o2) -> o1[0] - o2[0]); + int size = 0; + int count = 0; + for(int i = 0; i < 24; i++){ + while(!pq.isEmpty() && pq.peek()[0] == i){ + size -= pq.poll()[1]; + } + int need = players[i] / m; + int more = size - need; + if(more < 0){ + more = -more; + size += more; + count += more; + pq.add(new int []{i + k, more}); + } + } + return count; + } +} +```