Someone help me with this problem please!

Revision en2, by adsijf, 2021-05-16 07:05:01

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 : 10 4
        2 3 4 5
Output : 4

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English adsijf 2021-05-17 16:50:38 65
en2 English adsijf 2021-05-16 07:05:01 24 Tiny change: ' Input : 2 3 4 5\n' -> ' Input : 10 4\n 2 3 4 5\n'
en1 English adsijf 2021-05-16 07:02:58 623 Initial revision (published)