#K7516. Taco: Well Placement for House Coverage

    ID: 34358 Type: Default 1000ms 256MiB

Taco: Well Placement for House Coverage

Taco: Well Placement for House Coverage

You are given N houses located at different positions on a horizontal line, and you have M wells available. Each well has a range D which covers houses within a distance of D to the left and right of the well's placement. Your task is to determine if it is possible to place the M wells such that every house falls within the coverage range of at least one well.

In mathematical terms, if you choose a well position x, it covers all houses at positions in the interval \( [x-D, x+D] \). Given the sorted positions of the houses, decide if there exists a placement strategy using at most M wells so that for each house at position \( h_i \), there is at least one well placed such that \( |h_i - x| \le D \).

Note: If M = 0, then it is impossible to cover any house unless there are no houses. You can assume that the list of house coordinates is given in increasing order.

inputFormat

The input is provided via standard input (stdin) and consists of two lines:

  1. The first line contains three space-separated integers: (N) (the number of houses), (M) (the number of wells), and (D) (the range of each well).
  2. The second line contains (N) space-separated integers representing the coordinates of the houses (sorted in increasing order).

For example:

5 2 3 1 2 5 8 12

outputFormat

Output a single line via standard output (stdout) containing either "YES" if it is possible to place the wells in such a way that every house is covered, or "NO" otherwise.## sample

5 2 3
1 2 5 8 12
YES