leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1760.cpp (473B)
0 class Solution {
1 public:
2 int minimumSize(const vector<int> &nums, const int maxOperations) const {
3 int low = 1, high = 1E9;
4 while (low <= high) {
5 const int mid = low + (high - low) / 2;
6 int op = 0;
7 for (const int n : nums)
8 op += (n - 1) / mid;
9 if (op > maxOperations)
10 low = mid + 1;
11 else
12 high = mid - 1;
13 }
14 return low;
15 }
16 };