7

Computing minimum absolute summation of difference

 1 year ago
source link: https://codeforces.com/blog/entry/109198?f0a28=1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Computing minimum absolute summation of difference

By gXa, 5 hours ago,

I need to choose m elements, from an original array of size n, where m <= n. m will be supplied in the input, along with an array of size n.

The absolute difference among all pairs of elements between chosen m elements and the original array should be minimum, that is, for each element in the subarray, its absolute difference is computed from elements of the original leftover array (after removing m elements), and finally, summation of all the differences is done.

How can I compute the minimum summation of difference?

One example:

Original array: 1,4,6,10
n = 4
m = 2

Selected 2 elements = {4,6}
Minimum summation of difference = 18
=> |1-4| + |1-6| + |4-10| + |6-10|

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK