Advertisement
pacho_the_python

Untitled

Feb 9th, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. number_of_tourists = int(input())
  2.  
  3. places = input().split()
  4.  
  5. places = [int(i) for i in places]
  6.  
  7. full_wagon = []
  8.  
  9. not_lifted_tourists = False
  10. all_good = False
  11.  
  12. free_spots_sum = 0
  13.  
  14. for k in places:
  15.     empty_spot = 4 - k
  16.     free_spots_sum += empty_spot
  17.  
  18. if free_spots_sum < number_of_tourists:
  19.     not_lifted_tourists = True
  20. elif free_spots_sum == number_of_tourists:
  21.     all_good = True
  22.  
  23. for j in places:
  24.     free_spots = 4 - j
  25.     if number_of_tourists >= free_spots:
  26.         number_of_tourists -= free_spots
  27.         full_wagon += str(j + free_spots)
  28.  
  29.     elif number_of_tourists < free_spots:
  30.         full_wagon += str(j + number_of_tourists)
  31.         number_of_tourists -= number_of_tourists
  32.  
  33.     elif number_of_tourists == 0:
  34.         pass
  35.  
  36. if all_good:
  37.     print(" ".join(full_wagon))
  38.  
  39. elif not_lifted_tourists:
  40.     print(f"There isn't enough space! {number_of_tourists} people in a queue!")
  41.     print(" ".join(full_wagon))
  42.  
  43. else:
  44.     print("The lift has empty spots!")
  45.     print(" ".join(full_wagon))
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement