#K49062. Minimize Subset Difference

    ID: 28559 Type: Default 1000ms 256MiB

Minimize Subset Difference

Minimize Subset Difference

You are given an integer n representing the total number of integers, an integer k representing the size of a subset you need to select, and a list of n integers. Your task is to choose a subset of exactly k integers from the given list such that the difference between the maximum and minimum integers in the subset is minimized. In other words, if the chosen subset is S, you need to minimize

max(S)min(S)\max(S)-\min(S)

If it is impossible to choose such a subset (i.e. k > n), output No. Otherwise, output the chosen subset in increasing order. If there are multiple valid answers, you may output any one of them.

inputFormat

The input is read from stdin and consists of two lines:

  • The first line contains two integers n and k separated by a space.
  • The second line contains n space-separated integers.

outputFormat

If a valid subset exists, print the k integers in increasing order, separated by a single space. Otherwise, print No. The output is printed to stdout.

## sample
6 3
10 20 30 40 50 60
10 20 30