Loading...
Loading...
Loading...
Each step of a staircase has a fee that is paid when you leave that step. You may start on step 0 or on step 1, and you may move up one or two steps. Print the lowest total fee to get past the last step.
Example 1
Input
10 15 20
Output
15
Start on the step with fee 15 and jump two steps.
Example 2
Input
1 100 1 1 1 100 1 1 100 1
Output
6
Try the problem first. Open one hint at a time.
The cheapest cost to stand on position i comes from position i - 1 or i - 2 plus that step's fee.
Both starting positions cost 0, and the finish is position n.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor