#C10092. Minimize Maximum Time
Minimize Maximum Time
Minimize Maximum Time
In a coding competition, teams are required to solve exactly N problems out of a total of K available problems. Each problem has a difficulty representing the time required to solve that problem. The goal is to minimize the maximum time required among the selected problems.
Formally, you are given an integer \(K\) (the total number of problems), an integer \(N\) (the number of problems to be solved), and a list \(D = [d_1, d_2, \dots, d_K]\) where each \(d_i\) (for \(1 \le i \le K\)) represents the time required to solve the \(i\)-th problem. After sorting the list in non-decreasing order to obtain \(d_{(1)} \le d_{(2)} \le \cdots \le d_{(K)}\), the answer is given by \(d_{(N)}\).
Your task is to compute and output the minimum possible maximum time required to solve exactly \(N\) problems.
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains two integers \(K\) and \(N\) separated by a space, where \(K\) is the total number of problems and \(N\) is the number of problems to solve.
- The second line contains \(K\) space-separated integers representing the difficulties (time required) of each problem.
outputFormat
Output a single integer to stdout, which is the minimum possible maximum time required among the selected \(N\) problems.
## sample5 3
2 5 3 6 1
3