codeisneverodd/programmers-coding-test

입국심사 정답 | codeisneverodd

codeisneverodd opened this issue · 0 comments

제출한 정답

function solution(n, times) {
  let [l, r] = [1, 1_000_000_000 * n];

  while (l <= r) {
    const mid = Math.floor((l + r) / 2);
    const possibleN = times.reduce((a, time) => a + Math.floor(mid / time), 0);
    if (possibleN < n) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return l;
}

풀이 데이터

{
  "probId": "43238",
  "author": "codeisneverodd",
  "lang": "JavaScript",
  "createdAt": 1679461931240
}