From 894f07f0a0661847b67891da9b4c356a75074210 Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Tue, 4 Nov 2025 23:04:30 +0900 Subject: [PATCH] =?UTF-8?q?[20251004]=20PGM=20/=20LV2=20/=20=EB=8D=94=20?= =?UTF-8?q?=EB=A7=B5=EA=B2=8C=20/=20=EC=9D=B4=EC=9D=B8=ED=9D=AC?= 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" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "LiiNi-coder/202511/04 PGM \353\215\224 \353\247\265\352\262\214.md" diff --git "a/LiiNi-coder/202511/04 PGM \353\215\224 \353\247\265\352\262\214.md" "b/LiiNi-coder/202511/04 PGM \353\215\224 \353\247\265\352\262\214.md" new file mode 100644 index 00000000..36a4b575 --- /dev/null +++ "b/LiiNi-coder/202511/04 PGM \353\215\224 \353\247\265\352\262\214.md" @@ -0,0 +1,25 @@ +```java +import java.util.*; + +class Solution { + public int solution(int[] scoville, int K) { + int answer = 0; + Queue q = new PriorityQueue(); + for(int s: scoville){ + q.offer(s); + } + boolean isImpossible = false; + while(q.peek() < K){ + if(q.size() < 2){ + isImpossible = true; + break; + } + int s1 = q.poll(); + int s2 = q.poll(); + q.offer(s1 + s2*2); + answer++; + } + return (isImpossible)? -1 : answer; + } +} +```