Deleting Numbers
Practice
4.1 (29 votes)
Basic programming
Basics of implementation
Easy
Implementation
Problem
94% Success 8485 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB 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.

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...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
65 votes
Tags:
Basic ProgrammingMath BasicBasics of ImplementationC++
Points:20
20 votes
Tags:
ArraysBasic ProgrammingEasy
Points:20
17 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementation