#P1052. Frog on the Bridge

    ID: 12536 Type: Default 1000ms 256MiB

Frog on the Bridge

Frog on the Bridge

A frog stands at the beginning of a narrow log bridge over a river. The bridge can be represented as integer points from $0$ to $L$, where $0$ is the starting point and $L$ is the end point. Some of these positions have stones, and the frog dislikes stepping on them.

The frog can jump forward from its current position by any integer distance between $S$ and $T$ (inclusive). When the frog jumps to or beyond position $L$, it is considered to have crossed the bridge.

You are given the length of the bridge $L$, the range of jump distances $S$ and $T$, and the positions of the stones on the bridge. Your task is to determine the minimum number of stones the frog must land on in order to cross the bridge.

inputFormat

The input consists of three parts:

  1. The first line contains three integers: $L$, $S$, and $T$, where $L$ ($L\ge1$) is the length of the bridge, and $S$, $T$ ($1\le S\le T$) are the minimum and maximum jump distances.
  2. The second line contains an integer $N$, the number of stones placed on the bridge.
  3. The third line contains $N$ distinct space-separated integers indicating the stone positions on the bridge.

Note: It is guaranteed that all stone positions are between $0$ and $L$ (the endpoints might or might not contain stones).

outputFormat

Output a single integer, the minimum number of stones the frog must land on to cross the bridge.

sample

10 2 4
3
3 5 7
0