Tap here to switch tabs
Problem
Submissions

Problem: Maximum Candies Allocated to K Children

Try to solve the Maximum Candies Allocated to K Children problem.

Statement

You are given a 00 indexed integer array candies, where each candies[i] denotes the number of candies in the iith pile. You are also given an integer k.

You can divide any pile into any number of smaller subpiles, but you cannot merge different piles together.

You want to distribute the candies such that each of the k children gets the same number of candies. Each child can receive at most one subpile of candies, and some candies may remain unused.

Return the maximum number of candies each child can obtain. If it is impossible to distribute at least 11 candy to each child, return 00.

Constraints:

  • 1≤1 \leq candies.length ≤105\leq 10^5

  • 1≤1 \leq candies[i] ≤107\leq 10^7

  • 1≤1 \leq k ≤1012\leq 10^{12}

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Candies Allocated to K Children

Try to solve the Maximum Candies Allocated to K Children problem.

Statement

You are given a 00 indexed integer array candies, where each candies[i] denotes the number of candies in the iith pile. You are also given an integer k.

You can divide any pile into any number of smaller subpiles, but you cannot merge different piles together.

You want to distribute the candies such that each of the k children gets the same number of candies. Each child can receive at most one subpile of candies, and some candies may remain unused.

Return the maximum number of candies each child can obtain. If it is impossible to distribute at least 11 candy to each child, return 00.

Constraints:

  • 1≤1 \leq candies.length ≤105\leq 10^5

  • 1≤1 \leq candies[i] ≤107\leq 10^7

  • 1≤1 \leq k ≤1012\leq 10^{12}