Close equal numbers

Given an integer number k and n numbers x₁, …x_(n), are there at least
two equal numbers at distance at most k? Consider the sequence of
x_(i)’s circularly, that is, assume that x₁ is to the right of x_(n).

Input

Input consists of several cases, each with k and n, followed by
x₁, …x_(n). You can assume 1 ≤ k ≤ n/2, 2 ≤ n ≤ 10⁵, and that each x_(i)
is an integer number between 0 and 10⁹.

Output

For every case, print “yes” if there is at least a pair of x_(i)’s with
the required condition, and print “no” otherwise.

Problem information

Author: Javier Nistal

Generation: 2026-01-25T11:16:33.182Z

© Jutge.org, 2006–2026.
https://jutge.org
