Deleting Numbers

4.1

29 votes
Basic Programming, Basics of Implementation, Easy, Implementation
Problem

Zenyk recently got an array with his n school grades a1,a2,...,an. 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(m+1)/2 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(1k<n105) --- the number of Zenyk's grades and the number of grades Zenyk should delete, respectively.
The second line contains n integers a1,a2,...,an (1ai109) --- Zenyk's grades.

Output format

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

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

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

Editor Image

?