Problem 4009 · Hard

Minimum Possible Maximum Waiting Time

Cars take turns, in order, choosing one of two fuel dispensers with enough fuel; a car then waits for its dispenser, and the next car may choose once it starts. First serve as many cars as possible, then among those plans minimise the longest wait; return -1 if the first car cannot be served.

Open the interactive visualisation