It 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!

Input

The 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.

Output

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.

Example

Input

3

5 1

3

3 3

1 2 3

4 1

1

Output

3

1

4

Note

The 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.

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int t,n,k,x;
int a[210];
int cnt;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("in","r",stdin);
cin >> t;
while(t--){
cnt = 0;
cin >> n >> k;
int i;
for(i = 1; i <= k; i++)
cin >> a[i];
cnt = max(a[1]-1,n - a[k]);//两边水龙头据边界花费的时间
for(int i = 1; i < k; i++){
int juli = a[i + 1] - a[i] - 1;//水龙头中间的距离
if(juli & 1)
juli = juli / 2 + 1;
else juli = juli / 2;
cnt = max(cnt,juli);
}
cout << cnt + 1 << endl;
}
return 0;
}

找花费的时间,

1,找边界,取最大值

2中间两个水龙头的距离,分奇偶,偶/=2;奇/=2 + 1;

3不要忘记加1,本身

我也不知道为什么当时不会哎

C - Water The Garden的更多相关文章

  1. 【Educational Codeforces Round 37 A】 Water The Garden

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 记录下水龙头在哪些位置. 然后每秒钟把index-i和index+i改变状态一下就好(置1 [代码] #include <bi ...

  2. CF 920A Water The Garden

    本题可以看做是一个数学题 因为 在第 1 和第 3 个洒水器之间的 花园灌溉的时间只要 (1 + 3 ) >> 1 - 1 + 1;//这么长的时间 那么我么就可以以此类推到 从而我么可以 ...

  3. D - Garden

    Problem description Luba thinks about watering her garden. The garden can be represented as a segmen ...

  4. Genesis 2.8-2.12

    And the LORD God planted a garden eastward in Eden; and there he put the man whom he had formed. 9 A ...

  5. Educational Codeforces Round 37

    Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. W ...

  6. 新概念英语(1-125)Tea for two

    Does Susan have tea by herself?A:Can't you come in and have tea now,Peter? Not yet.B:I must water th ...

  7. Codeforces Educational Round 37

    Solved   CodeForces 920A Water The Garden   Solved   CodeForces 920B Tea Queue   Solved   CodeForces ...

  8. 第一册:lesson 125.

    原文: Tea for two. question:Does Susan have tea by herself? Can't you come in and have tea now Piter? ...

  9. Educational Codeforces Round 37 A B C D E F

    A. water the garden Code #include <bits/stdc++.h> #define maxn 210 using namespace std; typede ...

随机推荐

  1. mysql 查询时间戳格式化 和thinkphp查询时间戳转换

    我在网上看了好多写的,都差不多,甚至好多都是一个人写的被别人转载啥的,哎 我写一个比较简单的 1.mysql语句 格式化时间戳 select id,name,FROM_UNIXTIME(time,'% ...

  2. Linux使用mount挂载samba共享文件夹

    挂载smb的目录,使用读写644权限 mount -t cifs -o "rw,dir_mode=0644,file_mode=0644,username=username,password ...

  3. 如何预测股票分析--自动ARIMA

    在上一篇中,我们发现knn和线性回归一样,表现的不是特别好,来看看时间序列的表现 时间序列预测法其实是一种回归预测方法,属于定量预测,其基本原理是;一方面承认事物发展的延续性,运用过去时间序列的数据进 ...

  4. 【网易官方】极客战记(codecombat)攻略-地牢-焰中舞动

    关卡连接: https://codecombat.163.com/play/level/fire-dancing 用循环节省输入并拯救英雄! 简介: 左 右 起舞,避开火球. 使用 while tru ...

  5. Java 动态代理实现

    1.依赖 java.lang.reflect.Proxy - 提供了静态方法去创建动态代理类的实例: Interface InvocationHandler - 一个代理实例调用处理程序实现的接口 2 ...

  6. [lua]紫猫lua教程-命令宝典-L1-01-02. 变量

    L1[变量]01. 变量命名规则 命名规则:数字字母下划线构成 但是不能数字开头 不推荐中文名 很多都是不支持中文 但是在一些其他的编辑器里面 比如触摸精灵 之类的 就可以 注意 :变量命名必须要包含 ...

  7. C# 对象对比是否相等 工作笔记

    需要在Linq 中对比两个对象是否相等 /// <summary> /// 定义一个点 /// </summary> class Point { public int x { ...

  8. 503,display:none;与visibility:hidden;的区别

    联系:他们都能让元素不可见 区别: display:none:会让元素从渲染树中消失,渲染的时候不占据任何空间: visibility:hidden:不会让元素从渲染树中消失,渲染时袁旭继续占据空间, ...

  9. 每天进步一点点------CORDIC (一)

    三角函数计算,Cordic 算法入门 三角函数的计算是个复杂的主题,有计算机之前,人们通常通过查找三角函数表来计算任意角度的三角函数的值.这种表格在人们刚刚产生三角函数的概念的时候就已经有了,它们通常 ...

  10. 报bug mui分享微信 ,qq 分享失败

    1. iOS分享链接到微信,分享成功,但是分享的只有title,其他参数都没有 原因是mui分享进行了更新,msg新增了 msg.type 这个配置参数 qq : msg.type='text' 微信 ...