GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Longest increasing subsequence with maximum sum plus constraint - allowed number of elements can be skipped

The longest increasing subsequence with maximum sum (http://www.geeksforgeeks.org/dynamic-programming-set-14-maximum-sum-increasing-subsequence/) is a classic algorithm problem and there exist a lot of solutions on the web. However, I just encountered a variation of this problem and have no idea how to solve it.

Compared with the original question, now you are also given a number m which indicates the number of elements you can skip at most from a continuous sub-range in order to find the LIS with maximum sum. For example, with the following array,

[1, 200, 300, 3, 4, 5, 6]

The LIS is 1,3,4,5,6 and the maximum sum is 19. However, if m is 1, it means that at most one element can be skipped in a continuous sub-range in order to find the LIS. Hence the above solution is not right because between 1 and 3, two elements are skipped (200, 300 in this case). The new solution should be 3,4,5,6 since no elements are skipped in a continuous sub-range. The question is to find the LIS with the maximum sum and return the subsequence (not the sum or the length of the subsequence) when the array and the number m is given. I have been stuck with this problem for several days so any help is appreciated.

asked Aug 24, 2016 by Optimus Prime
...