AT_abc444_f [ABC444F] Half and Median
Description
There are $ N $ sticks, and the length of the $ i $ -th stick is $ A_i $ .
You will perform the following operation $ M $ times:
- Choose one stick of length at least $ 2 $ , and let $ l $ be the length of this stick. Divide this stick into two sticks of lengths $ \left\lfloor\frac{l}{2}\right\rfloor $ and $ \left\lceil\frac{l}{2}\right\rceil $ .
From the constraints, it can be proved that it is possible to perform the operation $ M $ times.
After $ M $ operations, $ N+M $ sticks will remain. Find the maximum possible value of the median of the lengths of these sticks.
Solve $ T $ test cases per input.
What is the median? When $ N $ is even, the median of $ N+1 $ numbers is the $ (1+\frac{N}{2}) $ -th value when they are sorted in ascending order.
For example, the median of $ (1,3,4,5,8) $ is $ 4 $ , and the median of $ (2,2,2) $ is $ 2 $ .
Note that in this problem, from the constraints, the number of sticks to consider for the median of lengths is always odd.
Input Format
The input is given from Standard Input in the following format:
> $ T $ $ case_1 $ $ case_2 $ $ \vdots $ $ case_T $
Each case is given in the following format:
> $ N $ $ M $ $ A_1 $ $ A_2 $ $ \ldots $ $ A_N $
Output Format
Output the answers in $ T $ lines in total. The $ t $ -th line should contain the answer for the $ t $ -th test case.
Explanation/Hint
### Sample Explanation 1
In the first test case, if you choose the stick of length $ 14 $ in the first operation, it is divided into two sticks of length $ 7 $ , and now you have six sticks of lengths $ 7,7,2,5,19,1 $ . If you choose the stick of length $ 19 $ in the second operation, it is divided into two sticks of lengths $ 9,10 $ , and now you have seven sticks of lengths $ 7,7,2,5,9,10,1 $ . In this case, the median of the stick lengths is $ 7 $ .
### Constraints
- $ 1 \leq T \leq 10^5 $
- $ 1 \leq N \leq 10^5 $
- $ 1 \leq A_i \leq 10^9 $
- $ 1 \leq M \leq \sum_{i=1}^{N}{A_i} - N $
- $ N+M $ is odd.
- The sum of $ N $ over all test cases is at most $ 10^5 $ .
- All input values are integers.