Company: Deutsche Bank
Difficulty: medium
Shopping and Billing A shop has `N` billing counters, numbered from 1 to `N`. `M` people arrive at the shop for billing; person `i` arrives at time `time[i]`. When a person arrives, they look at every counter and join the one with the **shortest queue**, where the length of a queue is the **number of people currently present at that counter** (the person being billed right now counts as present). If the chosen counter has nobody at it, the person is billed immediately; otherwise they wait behind the people already there. Billing one person takes exactly **1 unit of time**, and a counter starts billing the next person in its queue at the very instant the current person leaves. For every person, report the time at which they finish billing and leave the counter. Input format The first line contains the integer `N`, the number of counters. The second line contains the integer `M`, the number of persons. The third line contains `M` space-separated integers `time[0] time[1] ... time[M-1]`,