A Cappella Recording
InterviewTime limit1sMemory limit2048 MB
Given n pitches and a maximum allowed range d, find the fewest recordings so that each recording's max minus min pitch is at most d and every note is covered.
Problem
Geoffry is preparing an a cappella composition in which he sings the entire song by himself.
Each note of the song has a pitch between and . Because the pitches vary, Geoffry records himself singing several times. In a single recording, he picks some subset of the notes and sings exactly those notes. To avoid straining his voice, the difference between the maximum pitch and the minimum pitch among the notes in one recording is limited.
Compute the minimum number of recordings needed so that every note is sung in at least one of them.
Input
The first line contains two integers and (), where is the number of notes in the song and is the largest difference between the minimum and maximum pitch that Geoffry can handle.
Each of the next lines contains a single integer (), the pitches of the notes in the order they are to be sung.
Output
Output a single integer, the minimum number of recordings needed so that each note is sung in at least one of them.