Lily asked Huang Bo: “We have n ropes at
hand, and we want to cut them into some pieces. And we also want to get at
least k ropes with the same length. Can you give me the answer of the longest length
of these k ropes?” Huang Bo thought for a while and said that we can sort the
ropes by their length in descending order, and the kth biggest length is the
answer. Lily said: “No, you are wrong”. Lily is unhappy with Huang Bo’s answer,
and Huang Bo is in trouble, can you help him?
There are multiple test cases(less than
1000), for each test case, the first line will be two integers n and k( 0 <=
n <= 1000, 0 < k <= 10000), the second line will be n floating
numbers and the ith number is the length of i-th ropes, noted as ai (0<= ai
<= 100000). And all lengths in the input file are written with a centimeter precision, with exactly two digits after a decimal point.
One floating number the longest length of
these k ropes for each test case. Please notice that the number must be written with exactly two digits after decimal point.
Bonus problem. Binary search. Try to avoid doing binary search in floating numbers and pay attention to 0.