Approach hintTry it first, then revealHide
Simulate the line with a queue of (index, candies still needed): serve the front and push the child back while more candies are needed. Alternatively, compare ceil(a_i / m) directly and break ties by position.