Company: irage
Difficulty: medium
All the atms in the city are out of order so the citizens rush to banks to withdraw money. When you reach the bank, you find that there are n counters for withdrawing the cash and the counters are operated manually and are all labelled from 1,2,3...n and are placed sequentially. There is a long queue of customers, standing before counter number 1 and you join the queue at pth position. They go to counters which is available. One counter serves only one customer at any time. Each cashier works at different efficiency and thus takes different amount of time. Cashier at counter i takes t_i amount of time to verify the documents, bank records and finally hand you over the cash. While the bank is open, the customer who came in first heads to counter which is available. If more than one counter is free and available the customer always goes to the nearest counter. Bored of the long queue you start estimating which cashier will serve you. Given the time taken by each cashier and your position