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; + } +} +```