Educational Codeforces Round 37 (Rated for Div. 2)
2018-02-10 15:52
387 查看
A. Water The GardenA. Water The Gardentime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt is winter now, and Max decided it's about time he watered the garden.The garden can be represented as n consecutive garden beds, numbered from 1 to n. k beds contain water taps (i-th tap is located in the bed xi), which, if turned on, start delivering water to neighbouring beds. If the tap on the bed xi is turned on, then after one second has passed, the bed xi will be watered; after two seconds have passed, the beds from the segment [xi - 1, xi + 1] will be watered (if they exist); after j seconds have passed (j is an integer number), the beds from the segment [xi - (j - 1), xi + (j - 1)] will be watered (if they exist). Nothing changes during the seconds, so, for example, we can't say that the segment [xi - 2.5, xi + 2.5] will be watered after 2.5 seconds have passed; only the segment [xi - 2, xi + 2] will be watered at that moment.
The garden from test 1. White colour denotes a garden bed without a tap, red colour — a garden bed with a tap.
The garden from test 1 after 2 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!InputThe first line contains one integer t — the number of test cases to solve (1 ≤ t ≤ 200).Then t test cases follow. The first line of each test case contains two integers n and k (1 ≤ n ≤ 200, 1 ≤ k ≤ n) — the number of garden beds and water taps, respectively.Next line contains k integers xi (1 ≤ xi ≤ n) — the location of i-th water tap. It is guaranteed that for each
condition xi - 1 < xi holds.It is guaranteed that the sum of n over all test cases doesn't exceed 200.Note that in hacks you have to set t = 1.OutputFor 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.ExampleInput
There are 3 garden beds, and there is a water tap in each one. If we turn all of them on, then everything will be watered after 1 second passes.
There are 4 garden beds, and only one tap in the bed 1. It will take 4 seconds to water, for example, bed 4.
题目大意:
The garden from test 1. White colour denotes a garden bed without a tap, red colour — a garden bed with a tap.
The garden from test 1 after 2 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!InputThe first line contains one integer t — the number of test cases to solve (1 ≤ t ≤ 200).Then t test cases follow. The first line of each test case contains two integers n and k (1 ≤ n ≤ 200, 1 ≤ k ≤ n) — the number of garden beds and water taps, respectively.Next line contains k integers xi (1 ≤ xi ≤ n) — the location of i-th water tap. It is guaranteed that for each
condition xi - 1 < xi holds.It is guaranteed that the sum of n over all test cases doesn't exceed 200.Note that in hacks you have to set t = 1.OutputFor 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.ExampleInput
3 5 1 3 3 3 1 2 3 4 1 1Output
3 1 4NoteThe first example consists of 3 tests: There are 5 garden beds, and a water tap in the bed 3. If we turn it on, then after 1 second passes, only bed 3 will be watered; after 2 seconds pass, beds [1, 3] will be watered, and after 3 seconds pass, everything will be watered.
There are 3 garden beds, and there is a water tap in each one. If we turn all of them on, then everything will be watered after 1 second passes.
There are 4 garden beds, and only one tap in the bed 1. It will take 4 seconds to water, for example, bed 4.
题目大意:
相关文章推荐
- Educational Codeforces Round 37 (Rated for Div. 2) 920E E. Connected Components?
- Educational Codeforces Round 37 (Rated for Div. 2) E. Congruence Equation
- Educational Codeforces Round 37 (Rated for Div. 2)
- Educational Codeforces Round 37 (Rated for Div. 2) C. Swap Adjacent Elements
- Educational Codeforces Round 37 (Rated for Div. 2) F. SUM and REPLACE(线段树)
- Educational Codeforces Round 37 (Rated for Div. 2) E. Connected Components?(连通分量的个数,STL)
- Educational Codeforces Round 37 (Rated for Div. 2)F. SUM and REPLACE
- Educational Codeforces Round 37 (Rated for Div. 2)(A、B、C)
- Educational Codeforces Round 37 (Rated for Div. 2)-E-Connected Components?(模拟/暴力)
- Educational Codeforces Round 37 (Rated for Div. 2) 【F】【线段树】
- Educational Codeforces Round 37 (Rated for Div. 2)【A B C】【水】【模拟】
- Educational Codeforces Round 37 (Rated for Div. 2) F. SUM and REPLACE(线段树,区间更新)
- Wannafly挑战赛9+Educational Codeforces Round 37 (Rated for Div. 2)
- Educational Codeforces Round 37 (Rated for Div. 2)-F-SUM and REPLACE(线段树)
- [Codeforces]Educational Codeforces Round 37 (Rated for Div. 2)
- Educational Codeforces Round 37 (Rated for Div. 2)
- Codeforece Educational Codeforces Round 34 (Rated for Div. 2) (A-D)题解
- 【Educational Codeforces Round 41 (Rated for Div. 2) D】Pair Of Lines
- Educational Codeforces Round 35 (Rated for Div. 2)A,B,C
- codeforces Educational Codeforces Round 41 (Rated for Div. 2) for B problem