leetcode

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

2064.cpp (466B)


0 class Solution {
1 public:
2 int minimizedMaximum(const int n, const vector<int> &quantities) const {
3 int low = 1, high = 100000;
5 while (low <= high) {
6 int mid = low + (high - low) / 2, count = 0;
7 for (const int q : quantities)
8 count += (q + mid - 1) / mid;
10 if (count <= n)
11 high = mid - 1;
12 else
13 low = mid + 1;
14 }
16 return low;
17 }
18 };