Yet Another Black Cell Problem
Inspired by this problem.
There is a strip divided into cells numbered from to from left to right. Initially, all cells are white.
An array of length is given, containing the indices of cells. We want to paint all these cells black.
Given an integer , you may choose an integer such that , and then arbitrarily select cells that are not in . We also want to paint these selected cells black while keeping all non-selected cells white.
You may perform the following operation any number of times:
- Choose two distinct cells and such that , and paint them black, regardless of whether they were originally black or white.
Find the minimum value of for which it is possible to paint all the required cells black while keeping other cells white.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains two integers and ().
The second line contains integers (). It is guaranteed that for all .
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, print a single integer — the minimum value of for which it is possible to paint all the required cells black while keeping other cells white.
Note
In the first example, we cannot paint any cell other than and black because . So it's optimal to set and choose in the first operation.
In the second example, we can set , which is the minimal available value. We first choose to paint and then choose to paint. After that, cells are painted black, only cell is not in the given list, which satisfies the condition .
4 2 0 1 3 2 1 1 3 3 1 2 5 7 10 2 0 6 8 10 13 14 16 19 25 31
2 1 2 3
Discussions & Comments
Share your approach or ask questions about this problem (0)
You must be logged in to comment or start a discussion on this problem.
Log InNo comments yet. Be the first to comment!
Actions
Open on CodeforcesAbout Platform
Problem Discussions
0Have questions or want to share your solution approach? Join the discussion.
View / write comments