simeonshopov

Water dispenser

Mar 12th, 2020
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. from collections import deque
  2.  
  3. people = deque()
  4.  
  5. liters = int(input())
  6.  
  7. while True:
  8.     command = input()
  9.     if command == 'Start':
  10.         break
  11.     name = command
  12.     people.append(name)
  13.  
  14. while True:
  15.     command = input()
  16.     if command == 'End':
  17.         break
  18.     args = command.split()
  19.     if len(args) > 1:
  20.         quantity = int(args[1])
  21.         liters += quantity
  22.     else:
  23.         quantity = int(args[0])
  24.         if quantity <= liters:
  25.             print(f'{people.popleft()} got water')
  26.             liters -= quantity
  27.         else:
  28.             print(f'{people.popleft()} must wait')
  29.  
  30. print(f'{liters} liters left')
Advertisement
Add Comment
Please, Sign In to add comment