You are viewing a single comment's thread. Return to all comments →
C++ solution:
long lower_bound(std::vector<long>& m, long goal, long left, long right) { if (left > right) return left; long mid = (left+right)/2; unsigned long long result{0}; for(auto x : m) result += mid/x; if (result >= goal) return lower_bound(m, goal, left, mid-1); else return lower_bound(m, goal, mid+1, right); } long minTime(vector<long> machines, long goal) { return lower_bound(machines, goal, 0L, std::numeric_limits<long>::max());
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 →
C++ solution: