We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 9395cfc + d265731 commit 90be671Copy full SHA for 90be671
1 file changed
suyeun84/202510/08 PGM LV2 서버 증설 횟수.md
@@ -0,0 +1,24 @@
1
+```java
2
+import java.util.*;
3
+class Solution {
4
+ public int solution(int[] players, int m, int k) {
5
+ PriorityQueue<int[]> pq = new PriorityQueue<>((o1,o2) -> o1[0] - o2[0]);
6
+ int size = 0;
7
+ int count = 0;
8
+ for(int i = 0; i < 24; i++){
9
+ while(!pq.isEmpty() && pq.peek()[0] == i){
10
+ size -= pq.poll()[1];
11
+ }
12
+ int need = players[i] / m;
13
+ int more = size - need;
14
+ if(more < 0){
15
+ more = -more;
16
+ size += more;
17
+ count += more;
18
+ pq.add(new int []{i + k, more});
19
20
21
+ return count;
22
23
+}
24
+```
0 commit comments