C++ | Simple Binary Search Solution O(n*log(max(candies)))
\nclass Solution {\npublic:\n    bool check(vector<int>& arr,int mid, long long k){\n        long long count = 0;\n        for(int i : arr){\n            count 
```\nclass Solution {\npublic:\n    bool check(vector<int>& arr,int mid, long long k){\n        long long count = 0;\n        for(int i : arr){\n            count += (i/mid);\n        }\n        \n        return (count >= k);\n    }\n    \n    int maximumCandies(vector<int>& arr, long long k) {\n        int lo = 1, hi = *max_element(arr.begin(),arr.end()),ans = 0;        \n        while(lo <= hi){\n            int mid = lo + (hi - lo)/2;\n            if(check(arr,mid,k)){\n                ans = mid;\n                lo = mid + 1;\n            }else{\n                hi = mid - 1;\n            }\n        }\n        return ans;\n    }\n};\n```
['C', 'Binary Tree']