Advertisement
mbstanchev

lift

Jun 21st, 2022
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. waiting_people = int(input())
  2. lift_state = list(map(int, input().split()))
  3.  
  4. for current_cabin in range(len(lift_state)):
  5. if lift_state[current_cabin] == 0:
  6. if waiting_people >= 4:
  7. lift_state[current_cabin] += 4
  8. waiting_people -= 4
  9. if sum(lift_state) == len(lift_state) * 4 and waiting_people > 0:
  10. print(f"There isn't enough space! {waiting_people} people in a queue!")
  11. print(" ".join([str(num) for num in lift_state]))
  12. break
  13. elif sum(lift_state) == len(lift_state) * 4 and waiting_people == 0:
  14. print(" ".join([str(num) for num in lift_state]))
  15. break
  16.  
  17. else:
  18. lift_state[current_cabin] += waiting_people
  19. print(f"The lift has empty spots!")
  20. print(" ".join([str(num) for num in lift_state]))
  21. break
  22. else:
  23. diff = abs(lift_state[current_cabin] - 4)
  24. lift_state[current_cabin] += diff
  25. waiting_people -= diff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement