Lunar New Year and Food Ordering
MediumRating 1500CodeforcesDesign Data Structures
Approach hintTry it first, then revealHide
Sort the dish kinds once by cost and then index. A sold-out kind never returns, so a single pointer moving forward through that order always finds the cheapest kind still in stock; use 64-bit totals.