From 1855c555071d630be02b9f8ed13fd0cdea02d7e0 Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Fri, 14 Mar 2025 15:41:16 +0530 Subject: [PATCH] Create 2226. Maximum Candies Allocated to K Children --- 2226. Maximum Candies Allocated to K Children | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 2226. Maximum Candies Allocated to K Children diff --git a/2226. Maximum Candies Allocated to K Children b/2226. Maximum Candies Allocated to K Children new file mode 100644 index 0000000..f20a054 --- /dev/null +++ b/2226. Maximum Candies Allocated to K Children @@ -0,0 +1,11 @@ +class Solution { +public: + int maximumCandies(vector& A, long long k , int l = 0 , int r = 1e7) { + while(l < r){ + int m = (l + r + 1)/2; long s = 0; + for(auto p : A) s += p/m; + if(s < k) r = m - 1; else l = m; + } + return l; + } +};