~/algor $ cat problems/ikki-korsatkich-ayirmasi-k
Pair with difference k
Easy
1000 ms
128 MB
31%
$n$ integers $a_{1}, a_{2}, \dots, a_{n}$ sorted in non-decreasing order and an integer $k \ge 0$ are given. If the array has two elements at different positions ($i \lt j$) whose difference equals $k$, print YES, otherwise NO:
$$a_{j} - a_{i} = k$$
Input
The first line contains two integers: $n$ and $k$. The second line contains $n$ integers $a_{i}$ in non-decreasing order.
Output
YES or NO.
Note
$2 \le n \le 2 * 10^{5}$
$-10^{9} \le a_{i} \le 10^{9}$
$0 \le k \le 2 * 10^{9}$
Examples
Input #1
5 5 1 3 4 6 9
Output #1
YES
Input #2
4 0 1 2 3 4
Output #2
NO