Someone help me with this problem please!

Revision en1, by adsijf, 2021-05-16 07:02:58

Given an array a consisting of n elements, call array b consisting of n elements such that (a[1] — b[1])^2 + (a[2] — b[2])^2 + ... + (a[n] — b[n])^2 is minimum and sum of all elements of array B is equal to m.

Given n, array A, m, find the value of (a[1] — b[1])^2 + (a[2] — b[2])^2 + ... + (a[n] — b[n])^2.

Input : first line n,m respectively, second line is the elements of array A Output : the expected value

Ex: Input : 3 3 3 4 5 Output : 27

Input : 2 3 4 5
Output : 4

#### History

Revisions

Rev. Lang. By When Δ Comment