Millenium Jackson has a flood of infestation reports

$24.99 $18.99

Description Millenium Jackson has a flood of infestation reports coming in, and he needs to decide which ones to deal with first. Can you examine the size of each report and let him know which infestations are the largest? Input Format The first line has two values N and K. N is the number of…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:

Description

5/5 – (2 votes)

Description

Millenium Jackson has a flood of infestation reports coming in, and he needs to decide which ones to deal with first. Can you examine the size of each report and let him know which infestations are the largest?

Input Format

The first line has two values N and K. N is the number of reports coming in, and K is the number that Millenium can deal with this month.

The next N lines indicate the size of each infestation.

Constraints

1 ≤ N ≤ 107

1 ≤ K ≤ 1000

1 ≤ infestation size ≤ 109

Output Format

K values, indicating the K largest infestations in order (each on a new line).

Example 0

Sample Input

5 2

6

7

11

6

17

Sample Output

17

11

Explanation

There are five infestations, and we need to identify the largest two. They are size 17 and size 11.

Example 1

Sample Input

10 2

7

3

19

5

3

11

13

10

3

6

Sample Output

19

13

Millenium Jackson has a flood of infestation reports
$24.99 $18.99