Company: Deutsche Bank
Difficulty: medium
Shopping and Billing A shop has N billing counters, numbered 1 through N . M people arrive for billing. The i -th person arrives at time time[i] . The arrivals are given in non-decreasing order of time, so time[i] <= time[i + 1] . When a person arrives, they look at every counter and select the counter with the shortest queue , that is, the counter with the fewest people currently present at it. If several counters are tied for the fewest people, the person selects the one with the smallest counter number . If the selected counter is empty, the person is billed immediately; otherwise they stand at the back of that counter's queue. A counter takes exactly 1 unit of time to process one person's bill, and it starts on the next person in its queue immediately after the current person leaves. A person is counted as present at a counter from the moment they arrive until the moment they finish billing and leave. So a person who leaves at time x is no longer present at time x . For every pe