Deleting Numbers
Basic programming
Basics of implementation
Easy
Implementation
94.0% success
8,567 attempts
1s time
256MB memory
1024KB max code

Zenyk recently got an array with his \(n \) school grades \(a_1, a_2, ..., a_n\). He isn't very happy with them and knows that his parents also will not be happy with his grades. But he also knows that his parents evaluate his performance in a very strange way. They care only about the middle element in the array of grades Zenyk got. More formally if Zenyk's array is \(b\) and it has \(m \) elements, \(b_{\left\lfloor{(m+1)/2}\right\rfloor}\) is Zenyk's performance. Zenyk doesn't want to disappoint his parents, so he wants to erase exactly \(k (k < n)\) grades from his array \(a\) in order to maximize his score.

Input format

The first line contains two integers \(n, k (1 \le k < n \le 10^{5})\) --- the number of Zenyk's grades and the number of grades Zenyk should delete, respectively.
The second line contains \(n\) integers \(a_1, a_2, ..., a_n\) (\(1 \le a_i \le 10^{9}\)) --- Zenyk's grades.

Output format

You should output only one integer --- maximum score Zenyk can get.

Examples
Input
5 2
47 4 7 44 77
Output
44
Explanation

We can delete 4 and 7. Then the array will be 47, 44, 74. And the middle element will be 44.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading Editor...