Magic Moments

dhruba_1603088 Criterion 2020 Round 1
Limits 1s, 512 MB

You are going to a village by bus.

You need kk hours to do an important task while your bus journey will take nn hours.

You know that the speed of the fan in the bus changes every hour. The fan is measured on a scale from 0 to 100, where 0 is very slow and 100 is too fast. Bus authority has told you the fan speed schedule for all n hours.

You want to do your task only when the fan is fast, as much as possible. So, you have to choose kk hours from your bus journey when you will do the task such that minimum speed of fan among the selected hours is maximum.


The first input line contains two integers nn and kk (1n10001 ≤ n ≤ 1000, 1kn1 ≤ k ≤ n) — the number of hours on the bus and the number of hours to do the task. The second line contains nn space-separated integers aia_i (0ai1000 ≤ a_i ≤ 100), aia_i is the fan speed at the ii-th hour.


Print the minimum fan speed in which you will do the task.


15 1
0 78 24 24 61 60 0 65 52 57 97 51 56 13 10


Login to submit.



90% Solution Ratio
riyad000Earliest, Jan '20
riyad000Fastest, 0.0s
NX4338Lightest, 0 B
bokaifShortest, 72B
Toph uses cookies. By continuing you agree to our Cookie Policy.