2101-2110¶
2111-2120¶
2121-2130¶
2131-2140¶
2141-2150¶
2151-2160¶
2161-2170¶
2171-2180¶
2187. 完成旅途的最少时间
class Solution {
public:
#define ll long long
ll check(const vector<int> &time, ll x) {
ll sum = 0;
for (auto it: time) sum += x / it;
return sum;
}
long long minimumTime(vector<int> &time, int totalTrips) {
ll l = 1, r = (ll) totalTrips * *max_element(time.begin(), time.end()), mid = 0;
while (l < r) {
mid = l + r >> 1;
if (check(time, mid) >= totalTrips) r = mid;
else l = mid + 1;
}
return l;
}
};
2181-2190¶
2191-2200¶