Maximize Total Cost of Alternating Subarrays
Split the array into pieces whose alternating-sign costs sum to the largest total, using a prefix table of best splits.
Split the array into pieces whose alternating-sign costs sum to the largest total, using a prefix table of best splits.