Skip to content

Commit 20e3bb8

Browse files
authored
Create 2226. Maximum Candies Allocated to K Children (#740)
2 parents 46b3876 + 1855c55 commit 20e3bb8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public:
3+
int maximumCandies(vector<int>& A, long long k , int l = 0 , int r = 1e7) {
4+
while(l < r){
5+
int m = (l + r + 1)/2; long s = 0;
6+
for(auto p : A) s += p/m;
7+
if(s < k) r = m - 1; else l = m;
8+
}
9+
return l;
10+
}
11+
};

0 commit comments

Comments
 (0)