IntermediateRating 1300
Frog With Long Hops
Like Frog on Stones, but from stone i the frog may hop to any of i + 1, …, i + k. Print the least total cost to reach stone n.
Input
n and k, then n heights.
Output
One integer.
Sample 1
Input
5 3 10 30 40 50 20
Output
30
Sample 2
Input
3 1 10 20 10
Output
20
Output appears here