Problem 3196 · Medium

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.

Open the interactive visualisation