Question 7
There are stones, numbered . For each , the height of stone is . Assume these heights are stored in an array . We are also given an additional parameter which denotes the maximum jump length.
There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone :
- If the frog is currently on Stone , jump to one of the following: Stone .
- Here, a cost of is incurred, where is the stone to land on.
Our goal is to find the minimum possible total cost incurred before the frog reaches Stone .
Based on the above data, answer the given subquestions.