From 53384c872e33b0475e9eddf015bcf74f77a01d62 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Mon, 29 Sep 2025 17:46:26 +0900 Subject: [PATCH] =?UTF-8?q?[20250929]=20PGM=20/=20LV2=20/=20=EB=94=94?= =?UTF-8?q?=ED=8E=9C=EC=8A=A4=20=EA=B2=8C=EC=9E=84=20/=20=EA=B9=80?= =?UTF-8?q?=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...34\354\212\244 \352\262\214\354\236\204.md" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "suyeun84/202509/29 PGM LV2 \353\224\224\355\216\234\354\212\244 \352\262\214\354\236\204.md" diff --git "a/suyeun84/202509/29 PGM LV2 \353\224\224\355\216\234\354\212\244 \352\262\214\354\236\204.md" "b/suyeun84/202509/29 PGM LV2 \353\224\224\355\216\234\354\212\244 \352\262\214\354\236\204.md" new file mode 100644 index 00000000..2931de54 --- /dev/null +++ "b/suyeun84/202509/29 PGM LV2 \353\224\224\355\216\234\354\212\244 \352\262\214\354\236\204.md" @@ -0,0 +1,18 @@ +```java +import java.util.*; +class Solution { + public int solution(int n, int k, int[] enemy) { + int answer = enemy.length; + PriorityQueue pq = new PriorityQueue<>(); + + for (int i = 0; i < enemy.length; i++) { + pq.offer(enemy[i]); + + if(pq.size() > k) n -= pq.poll(); + + if (n < 0) return i; + } + return answer; + } +} +```