Close equal numbers P63257


Statement
 

pdf   zip

html

Given an integer number k and n numbers x1, … xn, are there at least two equal numbers at distance at most k? Consider the sequence of xi’s circularly, that is, assume that x1 is to the right of xn.

Input

Input consists of several cases, each with k and n, followed by x1, … xn. You can assume 1 ≤ kn/2, 2 ≤ n ≤ 105, and that each xi is an integer number between 0 and 109.

Output

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

Public test cases
  • Input

    4 8  10 42 23 33 12 42 17 18
    3 8  10 42 23 33 12 42 17 18
    4 7  10 42 23 33 12 42 17
    3 7  10 42 23 33 12 42 17
    

    Output

    yes
    no
    yes
    yes
    
  • Information
    Author
    Javier Nistal
    Language
    English
    Official solutions
    C++
    User solutions
    C++