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

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.kler.cn/a/312716.html

相关文章:

  • Day 63 || 拓扑排序、dijkstra
  • Vue中优雅的使用Echarts的三种方式
  • 力扣 LeetCode 977. 有序数组的平方(Day1:数组)
  • 软件测试学习记录 Day1
  • TCP可靠连接的建立和释放,TCP报文段的格式,UDP简单介绍
  • 数据库MySQL索引详解
  • LabVIEW提高开发效率技巧----使用事件结构优化用户界面响应
  • 【计算机网络 - 基础问题】每日 3 题(二)
  • JUC学习笔记(一)
  • 【Kubernetes】常见面试题汇总(十四)
  • 攻防演练篇:攻防演练场景中面临的常见加密威胁-HTTP隐蔽隧道
  • Lombok -----此java库 常用的注解及其功能总结
  • 前端vue-单选按钮的实现
  • Bigemap GIS Office 2024注册机 全能版地图下载软件
  • 操作系统的同步互斥
  • 分类预测|基于改进的灰狼IGWO优化支持向量机SVM的数据分类预测matlab程序 改进策略:Cat混沌与高斯变异
  • Echats 实现CPK (过程能力)研究报告
  • B+树(B+TREE)索引
  • Qt 模型视图(一):概述
  • 硬件工程师笔试面试——集成电路
  • 分布式消息服务Kafka版的详细解析和配置方式
  • 网络高级day01(Modbus 通信协议:Modbus TCP)
  • 【类型黑市】指针
  • Angular面试题四
  • 如何使用ssm实现企业人事管理系统+vue
  • monorepo基础搭建教程(从0到1 pnpm+monorepo+vue)