#C9481. Top K Most Liked Posts

    ID: 53579 Type: Default 1000ms 256MiB

Top K Most Liked Posts

Top K Most Liked Posts

You are given a user’s posts and the number of likes each post received. Your task is to determine the top k posts with the most likes and output them in non-increasing order.

The input consists of two values: an integer n representing the total number of posts, and an integer k representing the number of posts to output. The next line contains n space-separated integers, where each integer represents the number of likes of a post.

Your output should be the k most liked posts sorted in non-increasing order, separated by spaces.

For example, if n=5, k=3 and the list of likes is [10, 50, 20, 40, 30], then the output should be:

(50\ 40\ 30)

</p>

inputFormat

The first line of input contains two integers n and k separated by a space, where n is the total number of posts and k is the number of top liked posts required.

The second line contains n space-separated integers representing the number of likes for each post.

outputFormat

Output a single line containing k space-separated integers. These should represent the top k most liked posts in non-increasing order.

## sample
5 3
10 50 20 40 30
50 40 30

</p>