dimanche 27 février 2022

Choosing numbers from a vector so that the sum of their absolute differences is smaller than a given number [closed]

I have n integers in a file (unsorted and the numbers can repeat). I am given another integer S.

I have to find the maximum number of integers from the file so that the sum of their absolute differences is smaller than or equal to S.

For example, for 3 numbers, it means that

|x-y|+|x-z|+|y-z|<=S

Aucun commentaire:

Enregistrer un commentaire