Advertisement
GeorgiLukanov87

the_lift_90/100

May 20th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. people = int(input())
  2. wagons = list(map(int, input().split()))
  3. for lift in range(len(wagons)):
  4.  
  5.     if people < 4 and wagons[lift] < 4:
  6.         wagons[lift] += people
  7.         if wagons[lift] > 4:
  8.             waiting = wagons[lift] - 4
  9.             wagons[lift] -= waiting
  10.             people += waiting
  11.         break
  12.  
  13.     wagons[lift] += 4
  14.     people -= 4
  15.  
  16.     if wagons[lift] > 4:
  17.         waiting = wagons[lift] - 4
  18.         wagons[lift] -= waiting
  19.         people += waiting
  20.  
  21. available_space = False
  22. for w in wagons:
  23.     if int(w) < 4:
  24.         available_space = True
  25.         break
  26.  
  27. if available_space:
  28.     print('The lift has empty spots!')
  29.  
  30. elif people > 0 and wagons[-1] == 4:
  31.     print(f"There isn't enough space! {people} people in a queue!")
  32.  
  33. for el in wagons:
  34.     print(el, end=' ')
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement