leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
2187.cpp (447B)
0 class Solution { 1 public: 2 long long minimumTime(vector<int> &time, int totalTrips) { 3 long long low = 1, high = 1e14, mid, count; 4 while (low < high) { 5 mid = low + (high - low) / 2, count = 0; 6 for (long long t : time) 7 count += mid / t; 8 if (count >= totalTrips) 9 high = mid; 10 else 11 low = mid + 1; 12 } 13 return low; 14 } 15 };