orders[i] = [arrival, time] means a customer arrives at moment arrival and their drink takes time minutes to make. Customers are listed in the order they arrive.
The barista makes drinks strictly in turn, one at a time. If the barista is free when a customer arrives, work on their order starts right away; otherwise it starts as soon as the previous drink is done. A customer's waiting time runs from their arrival until their drink is ready.
Return the average waiting time over all customers. Answers within 10⁻⁵ of the exact value are accepted.orders=[[2, 3], [3, 1], [10, 2]] → 2.6666666666666665
The first order is ready at 5 (a wait of 3), the second starts at 5 and is ready at 6 (a wait of 3), the third starts at 10 and is ready at 12 (a wait of 2). Average: (3 + 3 + 2) / 3 ≈ 2.6667.
orders=[[1, 4], [1, 4]] → 6.0
Both arrive at 1: the first gets the coffee at 5 and the second at 9. Average: (4 + 8) / 2 = 6.
orders=[[2, 3], [3, 1], [10, 2]]
2.6666666666666665
Run checks the first 3 tests in your browser. Submit checks all 91 tests on the server, hidden ones included.