Skip to content

Commit 623380b

Browse files
Update searching.md
1 parent 774bee6 commit 623380b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎searching.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,26 @@ double minmaxGasDist(vector<int> &stations, int k)
10381038
}
10391039
```
10401040
1041+
### [Minimized Maximum of Products Distributed to Any Store](https://leetcode.com/problems/minimized-maximum-of-products-distributed-to-any-store/description/)
1042+
```cpp
1043+
int minimizedMaximum(int n, vector<int>& quantities){
1044+
function<bool(int)> check = [&](int x) -> bool{
1045+
int cnt = 0;
1046+
for (int quantity: quantities)
1047+
cnt += ceil((double)quantity / x);
1048+
return cnt <= n;
1049+
};
1050+
1051+
int l = 1, r = *max_element(quantities.begin(), quantities.end());
1052+
while (l < r){
1053+
int mid = l + (r-l)/2;
1054+
if (check(mid)) r = mid;
1055+
else l = mid + 1;
1056+
}
1057+
return l;
1058+
}
1059+
```
1060+
10411061
## Codeforces
10421062

10431063
*[Maximum Median](https://codeforces.com/contest/1201/problem/C): [https://codeforces.com/contest/1201/submission/76923324](https://codeforces.com/contest/1201/submission/76923324)

0 commit comments

Comments
(0)