Skip to content

Commit ff98cae

Browse files
authored
T : x 이분탐색
1 parent d2f06be commit ff98cae

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import java.util.*;
2+
class Solution {
3+
4+
public long solution(long n, int[] times) {
5+
long answer = 0;
6+
Arrays.sort(times);
7+
long st = 0;
8+
long en = times[times.length - 1] * n;
9+
// 0 60 30 6
10+
// 0 30 15 3
11+
// 15 30 22 5
12+
// 22 30 26 5
13+
// 26 30 28 6
14+
// 26 28 27 5
15+
16+
while(st < en){
17+
long m = (st + en) / 2;
18+
long comp = 0;
19+
for(long t : times){
20+
comp += m / t;
21+
}
22+
if(comp >= n){
23+
en = m;
24+
answer = m;
25+
}
26+
else {
27+
st = m + 1;
28+
}
29+
}
30+
return answer;
31+
}
32+
}

0 commit comments

Comments
 (0)