Q:

Jumps in sequence with max gain - Dynamic Programming

We have a sequence of items 1, ... , n and every item has a score(i).  If we choose an item then we can't choose the i+1, ... i+rest(i) items.  The goal is to maximize the total score. 
We can solve this with dynamic programming.  
For the first item we have two options.  Or to choose it and go to the rest(1) + 1 item or to not choose it and go to the second item. 
The recursive function:
c[i] = max{ c[i - 1], c[i + rest(i) + 1] + score(i) }

The problem with this recursive function is that it creates cycles between the sub problems meaning the sub problems are not independent. 
I think it would be ideal to have something like
c[i] = max{ c[i - 1], c[i - itemThatWentToItem(i)] + score(i) }

Maybe a solution would be to have a function that gives all the items that lead to item i and then take the max score between them. 
Another idea is to turn this problem to the Longest Path in a DAG and do it for all sub graphs. 
Any ideas? 

A:

Addition to the comment.  Yes, it can be implemented with recursion, something like:
def C(i, n):
  if i > n:
    return 0
  return max(C(i+1, n), C(i+rest(i)+1)+score(i))
print C(0,n)

It is the best (the fastest) to calculate values from the back.  Like (note: arrays is indexed 1 to n):
# initialize array with lot of zeros: length + max score(i)
cs = [0] * (n+max(rest(i) for i in range(0,n)+1)
for i in range(n, 0, -1):
  cs[i] = max(cs[i+1], cs[i+rest(i)+1]+score(i))
print cs[1]

