Learn this kind of Binary Search.
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
    search for each number of candies that k children can get equally
    until we get the maximum answer.
# Approach
<!-- Describe your approach to solving the problem. -->
    Use Binary Search to get the maximum number of candies that k
    children could divide equally.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
    O(n log(sum))

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
    O(1)
# Code
```cpp []
#define INCL()                                                                 \
    ios_base::sync_with_stdio(0);                                              \
    cin.tie(0);                                                                \
    cout.tie(0)

class Solution {
public:
    long long canFeed(long long candy, vector<int>& candies) {
        long long child = 0;

        for (int& currCandy : candies) {
            child += (currCandy / candy);
        }

        return child;
    }

    int maximumCandies(vector<int>& candies, long long k) {
        INCL();

        long long sum = accumulate(candies.begin(), candies.end(), 0LL);
        long long left = 1, right = sum;
        long long result = 0;

        while (left <= right) {
            long long mid = left + (right - left) / 2;
            if (canFeed(mid, candies) >= k) {    //can feed at least these many candies equally
                result = mid;
                left = mid + 1;
            } else {            //if we cannot feed these candies equally, check for less candies
                right = mid - 1;
            }   
        }

        return result;
    }
};
```
['Array', 'Binary Search', 'C++']