leetcode

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

0875.cpp (439B)


      1 class Solution {
      2   public:
      3     int minEatingSpeed(vector<int> &piles, int h) {
      4         int low = 1, high = INT_MAX, mid, count;
      5         while (low < high) {
      6             mid = low + (high - low) / 2, count = 0;
      7             for (int pile : piles)
      8                 count += ceil((double)pile / mid);
      9             if (count <= h)
     10                 high = mid;
     11             else
     12                 low = mid + 1;
     13         }
     14         return low;
     15     }
     16 };