We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents efed592 + 2dff07c commit 5a2ccb2Copy full SHA for 5a2ccb2
zinnnn37/202511/19 PGM LV2 더 맵게.md
@@ -0,0 +1,32 @@
1
+```java
2
+import java.util.PriorityQueue;
3
+import java.util.Queue;
4
+
5
+public class PGM_LV2_더_맵게 {
6
7
+ private static Queue<Integer> pq;
8
9
+ public int solution(int[] scoville, int K) {
10
+ int answer = 0;
11
12
+ pq = new PriorityQueue<>();
13
14
+ for (int s : scoville) {
15
+ pq.offer(s);
16
+ }
17
18
+ while (!pq.isEmpty() && pq.peek() < K) {
19
+ if (pq.size() < 2) return -1;
20
21
+ int a = pq.poll();
22
+ int b = pq.poll();
23
24
+ pq.offer(a + 2 * b);
25
+ answer++;
26
27
28
+ return answer;
29
30
31
+}
32
+```
0 commit comments