Problem 3979 · Medium

Maximum Valid Pair Sum

Pick two positions at least k apart and maximise their sum. Walking the right end forward while tracking the best value that is allowed to pair with it keeps the scan linear.

Open the interactive visualisation