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