Maximum Segment Sum After Removals
Run the removals backwards, putting values back and merging neighbouring segments with union-find, so each answer is the best segment sum at that moment.
Run the removals backwards, putting values back and merging neighbouring segments with union-find, so each answer is the best segment sum at that moment.