**PROBLEM LINK:** Exploring Undiscovered Planets

**AUTHOR:** tds115

**DIFFICULTY:** Easy-Medium

**PREREQUISITES:** DP, Heaps

The recurrence relation of the following problem can be defined as f(n)=a[n]+min( f(n-1),f(n-2),...,f(n-k)), where a[i] is the value of petrol per litre.

We can use the memorization technique to solve the following, to get minimum of last k elements we can maintain a heap.

Expected Solution - https://ideone.com/Dkil7V.