You are given a large barfi, which can be divided into n pieces, each weighing a1,…
- User
You are given a large barfi, which can be divided into n pieces, each weighing a1, a2,..., an. You need to distribute these pieces among k people such that:
• Each person receives contiguous pieces of the barfi.
• No piece is left undistributed.
Let w; be the total weight of the pieces received by the eth person. Define minShare as the minimum among the total weights each person receives, i.e., min(w₁, W2,..., wk).
Your task is to determine the maximum possible value of minShare when distributing the barfi pieces optimally.
Input
The first line contains two integers n and k (1≤ k ≤ n ≤10) the number of pieces and the number of people.
• The second line contains n integers a₁,a2.....an (1 ≤ n ≤10^4) the weights of the barfi pieces.
- Assistant