Skip to content

Commit ee32fae

Browse files
authored
Merge pull request #1448 from AlgorithmWithGod/0224LJH
[20251119] PGM / Lv2 / 서버 증설 횟수 / 이종환
2 parents 0a53f08 + 471a4da commit ee32fae

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
class Solution {
6+
public int solution(int[] players, int m, int k) {
7+
int len = players.length;
8+
int[] minus = new int[len];
9+
10+
int cur = 0;
11+
int total = 0;
12+
13+
for (int i = 0; i < len; i++){
14+
cur -= minus[i];
15+
16+
int limit = m*(cur+1);
17+
18+
if (players[i] < limit) continue;
19+
20+
int diff = players[i] - limit;
21+
22+
int plus = diff/m + 1;
23+
cur += plus;
24+
total += plus;
25+
26+
if (i+k < len){
27+
minus[i+k] = plus;
28+
}
29+
30+
}
31+
32+
int answer = total;
33+
return answer;
34+
}
35+
}
36+
```

0 commit comments

Comments
 (0)