Social Distance
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
People are standing in a queue to a store. The queue can be represented as a coordinate line. The \(i\)-th person is standing at coordinate \(x_i\).
As you know, in the middle of the COVID-19 pandemic, it is necessary to maintain social distance.
You need to tell whether the distance between every pair of people is at least 2 meters.
Input
The first line contains an integer \(n\) — the number of people in the queue.
The second line contains \(n\) integers — the coordinates of the people in the queue in meters, in order from left to right.
Output
In a single line, print YES if the people maintain the
distance, and NO otherwise.
Constraints
\(1 \le n \le 10^4\),
\(0 \le x_i \le 10^9\),
\(x_i \le x_{i+1}\),
for 40% of the tests, an additional constraint \(n \le 100\) is satisfied.
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 4 4 7 44 47 | YES |
| Input (stdin) | Output (stdout) |
|---|---|
| 7 1 2 3 4 5 6 7 | NO |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|