leetcode

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

1760.cpp (473B)


      1 class Solution {
      2   public:
      3     int minimumSize(const vector<int> &nums, const int maxOperations) const {
      4         int low = 1, high = 1E9;
      5         while (low <= high) {
      6             const int mid = low + (high - low) / 2;
      7             int op = 0;
      8             for (const int n : nums)
      9                 op += (n - 1) / mid;
     10             if (op > maxOperations)
     11                 low = mid + 1;
     12             else
     13                 high = mid - 1;
     14         }
     15         return low;
     16     }
     17 };