@coder42 For completeness here's my walking forward solution, O(B*n^2) time worst case (though much better average case and still beating 9%) and O(n^2) space (definitely not optimal!), basically storing the pair<smallest cost to that point, smallest lexicographically path to that point>, I used C++'s built comparison for pair and vector (element by element & lexicongraphical).

vector<int> cheapestJump(vector<int>& A, int B) {
int n=A.size();
vector<pair<long,vector<int>>> paths(n,{INT_MAX,{INT_MAX}});
paths[0]={0,{1}};
for (int i=0; i<n; i++) {
long coins=paths[i].first;
vector<int> path = paths[i].second;
for (int j=i+1; j<=i+B && j<n; j++) {
if (A[j]==-1) continue;
coins+=A[j];
path.push_back(j+1);
if (make_pair(coins,path} < paths[j]) paths[j]={coins,path};
coins-=A[j];
path.pop_back();
}
}
return paths[n-1].first==INT_MAX ? vector<int>() : paths[n-1].second;
}