Covering with intervals X11795


Statement
 

pdf   zip

Given a natural kk and several numbers x1,…,xnx_1, \ldots, x_n, we want to find the smallest possible set of closed intervals of length kk that cover those numbers. In other words, we must find a set of intervals {[y1,y1+k],…,[ym,ym+k]}\{[y_1, y_1 + k], \dots, [y_m, y_m + k]\} such that

  • for every xix_i, there exists some jj such that xi∈[yj,yj+k]x_i \in [y_j, y_j + k];

  • mm is minimum.

For instance, if k=10k=10 and the xix_i’s are 14,19,2314, 19, 23 and 2727, a possible solution is {[12,22],[1.8,2.8]}\{[12, 22], [1.8, 2.8]\}, since every xix_i belongs to (at least) one of the two intervals, and it is not possible to cover the four numbers with a single interval.

Input

Input consists of several cases, each of which starts with kk, followed by nn, followed by nn different numbers. All numbers in the input are integers. Assume 1≤k,n≤1051 \le k, n \le 10^5.

Output

For every case, print the minimum number of closed intervals of length kk that cover the given numbers.

Public test cases
  • Input

    10  4  14 19 23 27
    100 6  175 350 50 300 150 20
    10  2  -25 -35
    

    Output

    2
    3
    1
    
  • Information
    Author
    Language
    English
    Translator
    Enric Rodriguez
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Python
    User solutions
    C++ Python