Covering with intervals

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 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.

Problem information

Author: Unknown
Translator: Enric Rodriguez

Generation: 2026-01-25T11:53:52.306Z

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