Advertisement
CrayonCrayoff

Untitled

Jan 15th, 2025 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. def queue_time(customers: list[int], n: int) -> int:
  2.     if not customers:
  3.         return 0
  4.     if n == 1:
  5.         return sum(customers)
  6.     customer_amount = len(customers)
  7.     if customer_amount <= n:
  8.         return max(customers)
  9.  
  10.     customers.reverse()
  11.     tills = [0] * n
  12.     output = 0
  13.     while customers:
  14.         for idx in range(n):
  15.             if tills[idx] == 0 and customers:
  16.                 tills[idx] = customers.pop() - 1
  17.             else:
  18.                 tills[idx] -= 1
  19.         output += 1
  20.  
  21.     return output + max(tills)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement