You are viewing a single comment's thread. Return to all comments →
java solution -
static long minTime(long[] machines, long goal) { Arrays.sort(machines); long max = machines[machines.length - 1]; long minDays = 0; long maxDays = max*goal; long result = -1; while (minDays < maxDays) { long mid = (minDays + maxDays) / 2; long unit = 0; for (long machine : machines) { unit += mid / machine; } if (unit < goal) { minDays = mid+1; } else { result = mid; maxDays = mid; } } return result; }
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Time Required
You are viewing a single comment's thread. Return to all comments →
java solution -