Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- number_of_tourists = int(input())
- wagons = input().split()
- wagons = [int(i) for i in wagons]
- max_free_places = 4
- wagon_counter = 0
- while number_of_tourists > 0:
- if wagon_counter == len(wagons):
- break
- free_slots = max_free_places - wagons[wagon_counter]
- if free_slots > 0:
- if number_of_tourists > free_slots:
- wagons[wagon_counter] += free_slots
- number_of_tourists -= free_slots
- else:
- wagons[wagon_counter] += number_of_tourists
- number_of_tourists = 0
- wagon_counter += 1
- if wagons[-1] < max_free_places and number_of_tourists == 0:
- print("The lift has empty spots!")
- elif wagons[-1] == max_free_places and number_of_tourists > 0:
- print(f"There isn't enough space! {number_of_tourists} people in a queue!")
- print(f"{' '.join(map(str, wagons))}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement