#K60212. Top Scores with Ties

    ID: 31037 Type: Default 1000ms 256MiB

Top Scores with Ties

Top Scores with Ties

You are given a list of n scores and an integer p. Your task is to determine the top p scores in non-increasing order. However, if there are additional scores that are tied with the p-th score, they should also be included in the result.

In other words, if the p-th highest score is T, then you must output all scores s such that:

$$ s \geq T $$

The final list should be sorted in non-increasing order (from highest to lowest).

inputFormat

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

  • The first line contains two integers n and p where n is the number of scores and p is the number of top scores to initially consider.
  • The second line contains n integers separated by spaces representing the scores.

outputFormat

Output the selected scores in a single line in non-increasing order separated by a single space. The output is written to standard output.

## sample
5 3
50 80 80 70 90
90 80 80