Close equal numbers P63257


Statement
 

pdf   zip

Given an integer number kk and nn numbers x1,xnx_1, \dots x_n, are there at least two equal numbers at distance at most kk? Consider the sequence of xix_i’s circularly, that is, assume that x1x_1 is to the right of xnx_n.

Input

Input consists of several cases, each with kk and nn, followed by x1,xnx_1, \dots x_n. You can assume 1kn/21 \le k \le n/2, 2n1052 \le n \le 10^5, and that each xix_i is an integer number between 0 and 10910^9.

Output

For every case, print “yes” if there is at least a pair of xix_i’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++