I received a dynamic programming assignment and I need help figuring out the recurrence relation. The problem is similar to the weighted interval problem, but it has a few additional restrictions:
- You are given a series of
Ntime slots, each of the same duration. - Each time slot
k,0 <= k < N, is given a positive weightW[k]. - For any time interval
[i, j]withi < j, the weightW[i,j]of that interval is:
W[i,j] = W[i+1] + W[i+2] + ... + W[j]
Notice that the weightW[i]of the first time slot is not counted, hence any interval of length1has a weight of0.
You are given a value T < N and asked to select exactly T time slots such that the sum of the selected time intervals is maximized.
Example: For N = 5, T = 4 and the weights W = (3, 9, 1, 1, 7), selecting W[0, 1] = 9 and W[3, 4] = 7 will give a maximum weight of 16.