We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1e80abf commit 74f58c7Copy full SHA for 74f58c7
1 file changed
2025-09-08/김소희/프로그래머스_서버증설횟수.java
@@ -0,0 +1,28 @@
1
+class Solution {
2
+ static int[] server;
3
+ public int solution(int[] players, int m, int k) {
4
+ int answer = 0;
5
+ server = new int[24];
6
+ for(int i = 0; i < 24; i++){
7
+ //현재 필요한 서버 수 계산
8
+ int needServer = 0;
9
+ if(players[i] >= m){
10
+ if(players[i] % m == 0){
11
+ needServer += ((players[i] - m) / m) + 1;
12
+ }
13
+ else needServer += ((players[i] - m) / m) + 1;
14
15
+ int serverCount = 0;
16
+ for(int j = Math.max(0, i - k + 1); j < i; j++){
17
+ serverCount += server[j];
18
19
+
20
+ //필요한 서버 수 계산
21
+ int add = Math.max(0, needServer - serverCount);
22
+ server[i] = add;
23
+ answer += add;
24
25
26
+ return answer;
27
28
+}
0 commit comments