Note: This is an approximate problem. There is no exact solution. You must find the most optimal solution. Please, take a look at the sample explanation to ensure that you understand the problem correctly. Also, try not to use custom input, because the checker is specialized on test cases to check your submissions faster. Try to check your code on your own.
Problem statement
There are N+1 stones, numbered 1,2,…,N+1. For each i(1≤i≤N), the height of stone i is hi and the value of stone i is ai. There is a frog who is initially on stone 1. He will repeat the following action some number of times to reach stone N+1 : If the frog is currently on stone i, he can jump to the j -the stone if all of the following conditions are met:
Also, the frog has his lucky number k and he wants to reach stone N+1 in k steps so that sum of costs was minimized. Your task is to calculate the minimum sum of costs for him and find optimal jumps.
Input format
Output format
Verdict and scoring :
We can see that the first jump from 1 to 3 met all of the above-mentioned conditions. The maximum in this range is 3, which is no more than the width. The cost of this jump is 6. Now frog on the 4th stone.
We can see that the first jump from 4 to 5 met all of the above-mentioned conditions. The maximum in this range is 2, which is no more than the width. The cost of this jump is 2. Now frog on the 6th stone.
We can see that the first jump from 6 to 7 met all of the above-mentioned conditions. The maximum in this range is 2, which is no more than the width. The cost of this jump is 2. Now frog on the 8th stone.
We can see that the first jump from 8 to 10 met all of the above-mentioned conditions. The maximum in this range is 3, which is no more than the width. The cost of this jump is 6. Now frog on the 11th stone and finish.
Totally we have 6+2+2+6=16.