当前位置: 首页 > news >正文

A. Closest Point

time limit per test

2 seconds

memory limit per test

512 megabytes

Consider a set of points on a line. The distance between two points ii and jj is |i−j||i−j|.

The point ii from the set is the closest to the point jj from the set, if there is no other point kk in the set such that the distance from jj to kk is strictly less than the distance from jj to ii. In other words, all other points from the set have distance to jj greater or equal to |i−j||i−j|.

For example, consider a set of points {1,3,5,8}{1,3,5,8}:

  • for the point 11, the closest point is 33 (other points have distance greater than |1−3|=2|1−3|=2);
  • for the point 33, there are two closest points: 11 and 55;
  • for the point 55, the closest point is 33 (but not 88, since its distance is greater than |3−5||3−5|);
  • for the point 88, the closest point is 55.

You are given a set of points. You have to add an integer point into this set in such a way that it is different from every existing point in the set, and it becomes the closest point to every point in the set. Is it possible?

Input

The first line contains one integer tt (1≤t≤10001≤t≤1000) — the number of test cases.

Each test case consists of two lines:

  • the first line contains one integer nn (2≤n≤402≤n≤40) — the number of points in the set;
  • the second line contains nn integers x1,x2,…,xnx1,x2,…,xn (1≤x1<x2<⋯<xn≤1001≤x1<x2<⋯<xn≤100) — the points from the set.

Output

For each test case, print YES if it is possible to add a new point according to the conditions from the statement. Otherwise, print NO.

Example

Input

Copy

 

3

2

3 8

2

5 6

6

1 2 3 4 5 10

Output

Copy

YES
NO
NO

Note

In the first example, the point 77 will be the closest to both 33 and 88.

In the second example, it is impossible to add an integer point so that it becomes the closest to both 55 and 66, and is different from both of them.

解题说明:水题,只让插入一个数字而且要满足要求,肯定只能在2个数字中插入一个数字,其他不符合条件。两个数字中插入一个需要至少相减大于1.

#include<stdio.h>
#include<math.h>
int main()
{int t;scanf("%d", &t);while (t--){int n;scanf("%d", &n);int a[n];for (int i = 0; i < n; i++){scanf("%d", &a[i]);}if (n == 2 && abs(a[0] - a[1]) != 1){printf("YES\n");}else{printf("NO\n");}}return 0;
}

http://www.lryc.cn/news/442174.html

相关文章:

  • 沟通更高效:微信群转移至企业微信操作攻略!
  • 计算机毕业设计 基于Python Django的旅游景点数据分析与推荐系统 Python+Django+Vue 前后端分离 附源码 讲解 文档
  • 关于安卓App自动化测试的一些想法
  • Bigemap GIS Office 2024注册机 全能版地图下载软件
  • 秦时明月6.2魔改版+GM工具+虚拟机一键端
  • firewalld实现NAT端口转发
  • 中国电子学会202309青少年软件编程(Python)等级考试试卷(二级)真题
  • 第四天旅游线路预览——从贾登峪到喀纳斯景区入口(贾登峪游客服务中心)
  • 个人常用命令
  • 如何根据协议请求去捕捉在个文件中发出去的
  • Lombok -----此java库 常用的注解及其功能总结
  • 纯前端表格导出Excel
  • sourceTree保姆级教程7:(合并某次提交)
  • JVM面试知识点手册
  • Vue3.0组合式API:使用reactive()、ref()创建响应式代理对象
  • kubernetes调度2
  • Android中如何处理运行时权限?
  • 【PyCharm】PyCharm:让开发者效率倍增的编程利器
  • Spring Boot- 配置中心问题
  • 字符串专题-1
  • Unsupervised Deep Representation Learning for Real-Time Tracking
  • 第二讲 数据结构
  • docker部署excalidraw画图工具
  • 5G技术对IT行业的影响及未来发展
  • 字节跳动的微服务独家面经
  • 嵌套函数的例子(TypeScript)
  • 0915,SOCKET网络编程部分,三种I/O多路复用模型(select ,poll,epoll)
  • HarmonyOS 应用获取公钥和 MD5 指纹签名信息
  • 封装一个录音声音振动效果的组件
  • Java、JS与Go的扩展操作符,揭秘它们的‘魔法’!