Maximum Value Contiguous Subsequence problem solved using dynamic programming