当前位置: 首页 > 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.mrgr.cn/news/31382.html

相关文章:

  • 基于开源鸿蒙(OpenHarmony)的【智能家居综合应用】系统
  • OpenAI GPT o1技术报告阅读(3)-英文阅读及理解
  • ubuntu 20.04 ‘Wired Unmanaged‘ 网络无法配置解决方法
  • 八股文-多线程、并发
  • 小新-13 2019 Intel款IML版【81UQ】原装出厂Win10系统镜像下载
  • 缓存装饰器@cached_property
  • vulnhub(11):derpnstink(hydra爆破用户名和密码、验证的文件上传)
  • 变量的作用域和生命周期
  • React基础教程(10):React Hooks
  • 建筑工程五方责任主体项目负责人质量终身责任追究暂行办法
  • 哈希表的使用
  • Spring Boot中使用注解拦截器实现通用校验器和基于角色的权限注解
  • java之杨辉三角问题
  • A Simple Encoder-Decoder for Open-Vocabulary Semantic Segmentation
  • safepoint是什么?有什么用?
  • anaconda的windows新手安装及配置教程(适用于物联网工程、计算机专业)
  • Matlab R2024B软件安装教程
  • web基础—dvwa靶场(十)XSS
  • 极越联手百度这你受得了吗!SU7还能稳坐“7字辈”头把交椅?
  • 深入探索:深度优先遍历与广度优先遍历的奥秘与应用