From 2dff07c20f08126e744c74a8d15bd3123dbf2876 Mon Sep 17 00:00:00 2001 From: zinnnn37 Date: Wed, 19 Nov 2025 23:36:52 +0900 Subject: [PATCH] =?UTF-8?q?[20251119]=20PGM=20/=20LV2=20/=20=EB=8D=94=20?= =?UTF-8?q?=EB=A7=B5=EA=B2=8C=20/=20=EA=B9=80=EB=AF=BC=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... \353\215\224 \353\247\265\352\262\214.md" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "zinnnn37/202511/19 PGM LV2 \353\215\224 \353\247\265\352\262\214.md" diff --git "a/zinnnn37/202511/19 PGM LV2 \353\215\224 \353\247\265\352\262\214.md" "b/zinnnn37/202511/19 PGM LV2 \353\215\224 \353\247\265\352\262\214.md" new file mode 100644 index 00000000..3125e93d --- /dev/null +++ "b/zinnnn37/202511/19 PGM LV2 \353\215\224 \353\247\265\352\262\214.md" @@ -0,0 +1,32 @@ +```java +import java.util.PriorityQueue; +import java.util.Queue; + +public class PGM_LV2_더_맵게 { + + private static Queue pq; + + public int solution(int[] scoville, int K) { + int answer = 0; + + pq = new PriorityQueue<>(); + + for (int s : scoville) { + pq.offer(s); + } + + while (!pq.isEmpty() && pq.peek() < K) { + if (pq.size() < 2) return -1; + + int a = pq.poll(); + int b = pq.poll(); + + pq.offer(a + 2 * b); + answer++; + } + + return answer; + } + +} +``` \ No newline at end of file