Maximum Contiguous Subarray Dynamic Programming And Optimal Control