We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ab5a675 commit 53384c8Copy full SHA for 53384c8
1 file changed
suyeun84/202509/29 PGM LV2 디펜스 게임.md
@@ -0,0 +1,18 @@
1
+```java
2
+import java.util.*;
3
+class Solution {
4
+ public int solution(int n, int k, int[] enemy) {
5
+ int answer = enemy.length;
6
+ PriorityQueue<Integer> pq = new PriorityQueue<>();
7
+
8
+ for (int i = 0; i < enemy.length; i++) {
9
+ pq.offer(enemy[i]);
10
11
+ if(pq.size() > k) n -= pq.poll();
12
13
+ if (n < 0) return i;
14
+ }
15
+ return answer;
16
17
+}
18
+```
0 commit comments