leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2187.cpp (447B)


      1 class Solution {
      2   public:
      3     long long minimumTime(vector<int> &time, int totalTrips) {
      4         long long low = 1, high = 1e14, mid, count;
      5         while (low < high) {
      6             mid = low + (high - low) / 2, count = 0;
      7             for (long long t : time)
      8                 count += mid / t;
      9             if (count >= totalTrips)
     10                 high = mid;
     11             else
     12                 low = mid + 1;
     13         }
     14         return low;
     15     }
     16 };