Advertisement
viligen

lift

Oct 20th, 2021
1,133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. ppl = int(input())
  2.  
  3. lift_state = list(map(int, input().split()))
  4. max_capacity = 4
  5. out_list = []
  6. while ppl > 0 and len(out_list) < len(lift_state):
  7.     for wagon in lift_state:
  8.         free_space = max_capacity - wagon
  9.         if 0 < free_space <= ppl:
  10.             wagon = max_capacity
  11.  
  12.             ppl -= free_space
  13.         elif ppl < free_space:
  14.             wagon += ppl
  15.             ppl = 0
  16.         out_list.append(wagon)
  17. if ppl == 0 and len([n for n in out_list if n == max_capacity]) == len(out_list):
  18.     pass
  19. elif ppl == 0:
  20.     print("The lift has empty spots!")
  21. elif ppl > 0:
  22.     print(f"There isn't enough space! {ppl} people in a queue!")
  23.  
  24. print(*out_list)
  25.  
  26.  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement