1-liner Python / Ruby
Binary-search the smallest allocation a that\'s too large, the answer is 1 lower. Ruby still excels at this, though Python improved now that it supports a key.\
Binary-search the smallest allocation `a` that\'s too large, the answer is 1 lower. Ruby still excels at this, though Python improved now that it supports a `key`.\n\nRuby:\n```\ndef maximum_candies(candies, k)\n  (1..10**8).bsearch { |a| candies.sum { |c| c / a } < k } - 1\nend\n```\nPython:\n\n    def maximumCandies(self, candies: List[int], k: int) -> int:\n        return bisect_left(range(1, 10**8), True, key=lambda a: sum(c // a for c in candies) < k)\n
['Binary Tree', 'Python', 'Ruby']