LCC '22 Contest 4 J2 - C See Sea

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

To cope with his functions mark, Shane decides to go on a shopping spree.

Shane is looking for a new apartment, so he has compiled a list of N apartments from across the city, each with height h_i. His current apartment has a height of C, and he can just barely see the sea from this view.

The reason he is looking for a new apartment is for a better view of the sea, so he wants to move into an apartment where h_i \ge C. However, Shane is somewhat impatient and is only willing to check out a maximum of M apartments.

From his list, can you tell Shane the heights of the M tallest apartments that can see the sea? Note there may be fewer than M apartments that fulfill this requirement.

Constraints

1 \le M \le N \le 10^5

1 \le C, h_i \le 10^9

Input Specification

The first line of input contains three integers: N, M, and C.

The second line of input contains N integers, the heights of the N apartments on Shane's list.

Output Specification

On one line, output the heights of the M tallest buildings that can see the sea, from greatest to least. If there do not exist M apartments that fulfill this requirement, output the heights of those that do.

Sample Input 1

6 4 8
3 6 8 12 8 8 7

Sample Output 1

12 8 8 8

Sample Input 2

8 7 10
7 2 3 4 10 44 32 6

Sample Output 2

44 32 10

Sample 2 Explanation

There are only 3 apartments that can see the sea.


Comments

There are no comments at the moment.