Dsa
Dynamic Programming
Easy
Chocolate Distribution
You are given an integer array `chocolates` representing the number of chocolates available at different stores. Your goal is to distribute chocolates among `k` friends such that each friend gets the same number of chocolates and the total number of chocolates distributed is maximized. Write a program to find the maximum number of chocolates each friend can receive.
Input format:
- The first line contains two integers, `n` (1 ≤ n ≤ 1000) and `k` (1 ≤ k ≤ n).
- The second line contains `n` integers representing the `chocolates` array (1 ≤ chocolates[i] ≤ 10^6).
Output format:
- A single integer representing the maximum number of chocolates each friend can receive.
Example:
Input:
5 3
12 15 7 11 8
Output:
11
Key concepts
dynamic_programminggreedyarrays
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now