#C3289. Maximum Minimum Loyalty Points
Maximum Minimum Loyalty Points
Maximum Minimum Loyalty Points
You are given customers and gifts. Each customer has an associated loyalty point value. In order to maximize customer satisfaction, you want to distribute the gifts such that the minimum loyalty point among the chosen customers is as high as possible. Formally, you need to choose customers out of , and you would like to maximize the minimum loyalty point among those selected. It turns out that this is equivalent to selecting the customers with the highest loyalty points and then taking the largest value.
For example, if , and the loyalty points are [1, 2, 3, 4, 5], the optimal selection is to choose customers with points 5, 4, 3. The minimum among these is 3, which is the answer.
inputFormat
The input is given from standard input (stdin) as follows:
- The first line contains an integer , the number of customers.
- The second line contains an integer , the number of gifts to distribute.
- The third line contains space-separated integers representing the loyalty points of the customers.
It is guaranteed that .
outputFormat
Print a single integer to standard output (stdout) representing the maximum possible value among the minimum loyalty points of the customers who receive gifts.## sample
5
3
1 2 3 4 5
3
</p>