-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDH_43238.java
More file actions
37 lines (27 loc) Β· 828 Bytes
/
DH_43238.java
File metadata and controls
37 lines (27 loc) Β· 828 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
37
import java.util.*;
/*
μ
κ΅μ¬μ¬
*/
class DH_43238 {
public long solution(int n, int[] times) {
long answer = 0;
// μ
κ΅ μ¬μ¬ κΈ°κ°μ΄ μ£Όμ΄μ‘μ λ
// κ°μ₯ μ€λ 걸리λ μκ°μ ꡬνκΈ° μν΄ μ λ ¬ν΄μ€
Arrays.sort(times);
int length = times.length;
long s = 1, e = times[length - 1] * (long) n + 1; // μκ°μ΄
while(s < e) {
long m = (s + e) / 2;
// m μκ°μΌ λ, κ°λ₯ν μ¬λ μ
long peopleCnt = getPeopleCnt(m, times);
if(peopleCnt < n) s = m + 1;
else e = m;
}
return s;
}
static long getPeopleCnt(long time, int[] times) {
long peopleCnt = 0;
for(long t: times) peopleCnt += time / t;
return peopleCnt;
}
}