eolymp
bolt
Try our new interface for solving problems
Problems

Gap Existence

Gap Existence

You are given a sequence of $n$ numbers: $A = (a_1, a_2, ..., a_n)$. Determine whether there is a pair $(i, j)$ with $1 \le i, j \le n$ such that $a_i - a_j = x$. \InputFile The first line contains two numbers $n\:(2 \le n \le 2 \cdot 10^5)$ and $x\:(-10^9 \le x \le 10^9)$. The second line contains $n$ inegers $a_1, a_2, ..., a_n\:(-10^9 \le a_i \le 10^9)$. \OutputFile Print \textbf{Yes} if there is a pair $(i, j)$ with $1 \le i, j \le n$ such that $a_i - a_j = x$, and \textbf{No} otherwise.
Time limit 1 second
Memory limit 128 MiB
Input example #1
7 3
2 8 7 6 1 12 5
Output example #1
Yes
Input example #2
7 3
2 8 7 1 12 6 1
Output example #2
No