Problem 2517 · Medium
Binary search the answer gap and check each candidate with a greedy pick over the sorted prices.
Open the interactive visualisation