Water The Garden
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
题目描述
It is winter now, and Max decided it's about time he watered the garden.
The garden can be represented as consecutive garden beds, numbered from to . beds contain water taps ( -th tap is located in the bed ), which, if turned on, start delivering water to neighbouring beds. If the tap on the bed is turned on, then after one second has passed, the bed will be watered; after two seconds have passed, the beds from the segment will be watered (if they exist); after seconds have passed ( is an integer number), the beds from the segment will be watered (if they exist). Nothing changes during the seconds, so, for example, we can't say that the segment will be watered after seconds have passed; only the segment will be watered at that moment.
The garden from test . White colour denotes a garden bed without a tap, red colour — a garden bed with a tap.
The garden from test after seconds have passed after turning on the tap. White colour denotes an unwatered garden bed, blue colour — a watered bed. Max wants to turn on all the water taps at the same moment, and now he wonders, what is the minimum number of seconds that have to pass after he turns on some taps until the whole garden is watered. Help him to find the answer!
输入格式
The first line contains one integer — the number of test cases to solve ( ).
Then test cases follow. The first line of each test case contains two integers and ( , ) — the number of garden beds and water taps, respectively.
Next line contains integers ( ) — the location of -th water tap. It is guaranteed that for each
condition holds.
It is guaranteed that the sum of over all test cases doesn't exceed .
Note that in hacks you have to set .
输出格式
For each test case print one integer — the minimum number of seconds that have to pass after Max turns on some of the water taps, until the whole garden is watered.
样例
3
5 1
3
3 3
1 2 3
4 1
1
3
1
4
提示
The first example consists of tests:
- There are garden beds, and a water tap in the bed . If we turn it on, then after second passes, only bed will be watered; after seconds pass, beds will be watered, and after seconds pass, everything will be watered.
- There are garden beds, and there is a water tap in each one. If we turn all of them on, then everything will be watered after second passes.
- There are garden beds, and only one tap in the bed . It will take seconds to water, for example, bed .