CF920A.Water The Garden

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

It is winter now, and Max decided it's about time he watered the garden.

The garden can be represented as nn consecutive garden beds, numbered from 11 to nn . kk beds contain water taps ( ii -th tap is located in the bed xix_{i} ), which, if turned on, start delivering water to neighbouring beds. If the tap on the bed xix_{i} is turned on, then after one second has passed, the bed xix_{i} will be watered; after two seconds have passed, the beds from the segment [xi1,xi+1][x_{i}-1,x_{i}+1] will be watered (if they exist); after jj seconds have passed ( jj is an integer number), the beds from the segment [xi(j1),xi+(j1)][x_{i}-(j-1),x_{i}+(j-1)] will be watered (if they exist). Nothing changes during the seconds, so, for example, we can't say that the segment [xi2.5,xi+2.5][x_{i}-2.5,x_{i}+2.5] will be watered after 2.52.5 seconds have passed; only the segment [xi2,xi+2][x_{i}-2,x_{i}+2] will be watered at that moment.

The garden from test 11 . White colour denotes a garden bed without a tap, red colour — a garden bed with a tap. The garden from test 11 after 22 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 tt — the number of test cases to solve ( 1<=t<=2001<=t<=200 ).

Then tt test cases follow. The first line of each test case contains two integers nn and kk ( 1<=n<=2001<=n<=200 , 1<=k<=n1<=k<=n ) — the number of garden beds and water taps, respectively.

Next line contains kk integers xix_{i} ( 1<=xi<=n1<=x_{i}<=n ) — the location of ii -th water tap. It is guaranteed that for each condition xi1<xix_{i-1}<x_{i} holds.

It is guaranteed that the sum of nn over all test cases doesn't exceed 200200 .

Note that in hacks you have to set t=1t=1 .

输出格式

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.

输入输出样例

  • 输入#1

    3
    5 1
    3
    3 3
    1 2 3
    4 1
    1
    

    输出#1

    3
    1
    4
    

说明/提示

The first example consists of 33 tests:

  1. There are 55 garden beds, and a water tap in the bed 33 . If we turn it on, then after 11 second passes, only bed 33 will be watered; after 22 seconds pass, beds [1,3][1,3] will be watered, and after 33 seconds pass, everything will be watered.
  2. There are 33 garden beds, and there is a water tap in each one. If we turn all of them on, then everything will be watered after 11 second passes.
  3. There are 44 garden beds, and only one tap in the bed 11 . It will take 44 seconds to water, for example, bed 44 .
首页