[CPP] Binary Search || Easy to Understand
\nclass Solution {\npublic:\n    //checks if each children can get C candies\n    bool isPossible(vector<int>& candies, long long C, long long k) {\n        lon
```\nclass Solution {\npublic:\n    //checks if each children can get C candies\n    bool isPossible(vector<int>& candies, long long C, long long k) {\n        long long cnt = 0;\n        for(auto c : candies) {\n            cnt += (long long)(c/C);\n        }\n        \n        return cnt >= k;\n    }\n    \n    //Binary Search on ans(no. of candies each can get)\n    int maximumCandies(vector<int>& candies, long long k) {\n        long long sum = 0;\n        for(auto c : candies) sum += (long long)c;\n        \n        long long end = sum / k + 1;\n        long long beg = 0;\n        while(beg + 1 < end) {\n            long long mid = (beg + end) / 2;\n            if(isGood(candies, mid, k)) beg = mid;\n            else end = mid;\n        }\n        \n        return (int)beg;\n    }\n};\n```
[]