Leetcode算法题2101-2189


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


文章作者: 不二
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 不二 !
  目录