World Languages, asked by rawalrajesh43, 4 months ago

We have N number of orphans in an orphanage. Initially, each orphan has some or no books
with them and they are standing in a line.
Given an integer array representing B, the number of books with each orphan from left to rig
ht on the line, you should find the minimum number of moves to make all the orphans have
the same number of books.
If it is not possible to make same number of books with the orphans, then give the output as
For each move, you could choose any orphan and pass one book of each orphan to one of hi
s/her adjacent orphan at the same time.
Input Format:
The first line contains an integer N (number of orphans).
The next line contains N space separated integers of an array.
Constraint:
1 <= N <= 10^4
1 de B <= 10^5
Sample Input 1:​

Answers

Answered by pakhi6336
14

Answer:

Input : arr[] = {2, 7, 6, 1, 4, 5}, k = 3

Output : 6

The subarray is {7, 6, 1, 4} with sum 18.

Equal distribution of 18 chocolates among

3 students is 6.

Note that the selected boxes are in consecutive order

with indexes {1, 2, 3, 4}.

Similar questions