We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 46b3876 + 1855c55 commit 20e3bb8Copy full SHA for 20e3bb8
2226. Maximum Candies Allocated to K Children
@@ -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