-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJY_389479.java
More file actions
36 lines (28 loc) Β· 994 Bytes
/
JY_389479.java
File metadata and controls
36 lines (28 loc) Β· 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class JY_389479 {
public int solution(int[] players, int m, int k) {
int answer = 0;
int P = players.length;
int[] crr = new int[P+k+1];
int cnt = 0;
int s = 0;
int e = 0;
for(int i=0; i<P; i++) {
int p = players[i];
// iμκ°μ μ’
λ£λλ μλ² μ²λ¦¬
if(crr[i] != 0) {
cnt -= crr[i];
}
// μλ²λ₯Ό μ¦μ€ν΄μΌ ν¨
if(p >= ((cnt+1)*m)) {
s = i;
e = s + k;
// μΆκ°ν΄μΌν μλ² κ°μ
int nc = (p / m) - cnt;
crr[e] += nc; // μΆκ°ν μλ²λ€μ΄ λλλ μκ°μ κ°μ μ μ₯
cnt += nc; // μλ² μΆκ° μ¦μ€
answer += nc; // μ¦μ€ νμ μΉ΄μ΄νΈ
}
}
return answer;
}
}