Problem list
Log in
#coci00471 · COCI 2017/2018 Contest 4

Rasvjeta

Silver IV 1.0 s 256 MB

1 $s / 64$ $MB / 50$ points

It is Advent season. There are ​$M$ ​street lights in a street ​$N$ metres long (the meters of the

street are denoted with numbers from 1 to ​$N$​). Each of the lights lights up the meter of the

street it’s located in and ​$K$ meters to the left and to the right of that location. In other words, if

the light is located at meter ​$X$​, it lights up all metres of the street from ​$X - K$ to ​$X + K$​,

inclusively. Of course, it is possible for a meter of the street to be lit up by multiple street

lights. All lights have distinct locations.

The problem is that there is a possibility that the lights don’t light up all ​$N$ metres of the

street. It is your task to determine the minimal amount of additional lights needed to be put

up (at position from 1 to ​$N$​) so that the entire street is lit up.

Input

The first line of input contains the number ​$N$​ (1 ≤ ​$N$​ ≤ 1000). The second line of input contains the number ​$M$​ (1 ≤ ​$M$​ ≤ ​$N$​). The third line contains the number ​$K$​ (0 ≤ ​$K$​ ≤ ​$N$​). Each of the following ​$M$ lines contains a number. The numbers are sorted in ascending order

and represent the positions of each of the ​$M$​ street lights. The positions will be distinct and from the interval [1, ​$N$​].

Output

You must output the required number from the task.

Example 1

Input
5
2
2
1
5
Output
0

Example 2

Input
26
3
3
3
19
26
Output
2

Example 3

Input
13
2
10
1
2
Output
1
Source
COCI 2017/2018 Contest 4
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code