public long solution(int n, int[] times) {
Arrays.sort(times);
long start = 1;
long end = (long) times[times.length - 1] * n;
long answer = 0;
while (start <= end) {
long mid = (start + end) / 2;
long sum = 0;
for (int time : times) {
sum += mid / time;
}
if (sum >= n) {
end = mid - 1;
answer = mid;
} else {
start = mid + 1;
}
}
return answer;
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/43238