You are given an array a of n integers, where n is odd. You can make the following operation with it:
Choose one of the elements of the array (for example ai) and increase it by 1 (that is, replace it with ai+1).
You want to make the median of the array the largest possible using at most k operations.
The median of the odd-sized array is the middle element after the array is sorted in non-decreasing order. For example, the median of the array [1,5,2,3,5] is 3.
Input
The first line contains two integers n and k (1≤n≤2⋅105, n is odd, 1≤k≤109) — the number of elements in the array and the largest number of operations you can make.
The second line contains n integers a1,a2,…,an (1≤ai≤109).
Output
Print a single integer — the maximum possible median after the operations.
Examples
Input
3 2
1 3 5
Output
5
Input
5 5
1 2 1 1 1
Output
3
Input
7 7
4 1 2 4 3 4 4
Output
5
Note
In the first example, you can increase the second element twice. Than array will be [1,5,5] and it’s median is 5.
In the second example, it is optimal to increase the second number and than increase third and fifth. This way the answer is 3.
In the third example, you can make four operations: increase first, fourth, sixth, seventh element. This way the array will be [5,1,2,5,3,5,5] and the median will be 5.
题意
给你n个数以及k次操作,每次操作可以使一个数加一,输出这n个数操作结束后最大的中位数
思路
显然的,假若操作数k非常大,要使中位数尽可能的大,所有操作结束后,从中位数到第n个数之间的所有数都应该是相等的。
以此类推,我们只需要执行以下操作即可
1.将输入的数从小到大排序,前n/2个数不会影响到中位数,我们只需要考虑【n/2+1,n】个数
2.从中位数开始
3.判断当前k是否足够将当前数以及从当前数到中位数的所有数增加到下一个数
- 如果k足够,那么将当前数以及从当前数到中位数的所有数增加到下一个数,k减去该操作消耗的k的步数,将当前数+1并回到第二步
- k不足以使当前数以及从当前数到中位数的所有数增加到