solve that takes a subarray of slices and the number of slices to pick.prev, curr, and next, each with a length of n+2 where n is the number of slices.prev array with the maximum sum for each state.next two steps ahead, or not taking the slice and taking the sum from curr one step ahead.next becomes curr, and curr becomes prev.