Skip to content

Commit 90be671

Browse files
authored
[20251008] PGM / LV2 / 서버 증설 횟수 / 김수연
[20251008] PGM / LV2 / 서버 증설 횟수 / 김수연
2 parents 9395cfc + d265731 commit 90be671

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)