Advertisement
pacho_the_python

Untitled

Jun 17th, 2023
973
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. number_of_tourists = int(input())
  2. wagons = input().split()
  3.  
  4. wagons = [int(i) for i in wagons]
  5. max_free_places = 4
  6. wagon_counter = 0
  7. while number_of_tourists > 0:
  8.     if wagon_counter == len(wagons):
  9.         break
  10.     free_slots = max_free_places - wagons[wagon_counter]
  11.     if free_slots > 0:
  12.         if number_of_tourists > free_slots:
  13.             wagons[wagon_counter] += free_slots
  14.             number_of_tourists -= free_slots
  15.         else:
  16.             wagons[wagon_counter] += number_of_tourists
  17.             number_of_tourists = 0
  18.     wagon_counter += 1
  19.  
  20. if wagons[-1] < max_free_places and number_of_tourists == 0:
  21.     print("The lift has empty spots!")
  22. elif wagons[-1] == max_free_places and number_of_tourists > 0:
  23.     print(f"There isn't enough space! {number_of_tourists} people in a queue!")
  24. print(f"{' '.join(map(str, wagons))}")
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement