#P5613. Hikari and the Magic Platforms
Hikari and the Magic Platforms
Hikari and the Magic Platforms
Hikari is faced with a staircase consisting of $n$ steps ($1 \le n \le 1000$). Initially, she can jump up to $m$ steps in one second ($1 \le m \le n$). In each move, she may choose any integer jump length $d$ such that $1 \le d \le m$, and she lands directly on the $d$-th step from her current position (she does not pause on the intermediate steps).
There are $k$ special platforms on some steps ($k \le 10$). Their positions are given by $a_i$. Whenever Hikari lands exactly on a special platform, her maximum jump distance increases by $1$ (i.e. $m$ becomes $m+1$) for subsequent moves.
Your task is to compute the minimum amount of time (in seconds) required for Hikari to reach exactly the top of the staircase (i.e. step $n$).
Note: Hikari is allowed to choose any jump distance from $1$ up to her current maximum jump distance $m$. She must land exactly on step $n$ to finish.
inputFormat
The input consists of two lines. The first line contains three integers: $n$, $m$, and $k$, where $n$ is the total number of steps, $m$ is the initial maximum jump distance, and $k$ is the number of special platforms.
The second line contains $k$ distinct integers $a_1, a_2, \dots, a_k$ representing the positions of the special platforms. (If $k=0$, the second line will be empty.)
outputFormat
Output a single integer, which is the minimum number of seconds required for Hikari to reach step $n$.
sample
10 2 1
4
4