Upload code_segments/segment_240.txt with huggingface_hub
Browse files
code_segments/segment_240.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Consider a set of points on a line. The distance between two points $i$ and $j$ is $|i - j|$.
|
| 2 |
+
|
| 3 |
+
The point $i$ from the set is the closest to the point $j$ from the set, if there is no other point $k$ in the set such that the distance from $j$ to $k$ is strictly less than the distance from $j$ to $i$. In other words, all other points from the set have distance to $j$ greater or equal to $|i - j|$.
|
| 4 |
+
|
| 5 |
+
For example, consider a set of points $\\{1, 3, 5, 8\\}$:
|
| 6 |
+
|
| 7 |
+
* for the point $1$, the closest point is $3$ (other points have distance greater than $|1-3| = 2$); * for the point $3$, there are two closest points: $1$ and $5$; * for the point $5$, the closest point is $3$ (but not $8$, since its distance is greater than $|3-5|$); * for the point $8$, the closest point is $5$.
|
| 8 |
+
|
| 9 |
+
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?
|
| 10 |
+
|
| 11 |
+
The first line contains one integer $t$ ($1 \le t \le 1000$) — the number of test cases.
|
| 12 |
+
|
| 13 |
+
Each test case consists of two lines:
|
| 14 |
+
|
| 15 |
+
* the first line contains one integer $n$ ($2 \le n \le 40$) — the number of points in the set; * the second line contains $n$ integers $x_1, x_2, \dots, x_n$ ($1 \le x_1 < x_2 < \dots < x_n \le 100$) — the points from the set.
|
| 16 |
+
|
| 17 |
+
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.
|
| 18 |
+
|
| 19 |
+
In the first example, the point $7$ will be the closest to both $3$ and $8$.
|
| 20 |
+
|
| 21 |
+
In the second example, it is impossible to add an integer point so that it becomes the closest to both $5$ and $6$, and is different from both of them.
|