Advertisement
Guest User

The Lift

a guest
Nov 21st, 2021
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. waiting_people = int(input())
  2. lift_state = [int(s) for s in input().split()]
  3. the_lift_has_empty_slots = False
  4. for index in range(len(lift_state)):
  5.  
  6.     if lift_state[index] == 0 and waiting_people >= 4:
  7.         lift_state[index] += 4
  8.         waiting_people -= 4
  9.     else:
  10.         if lift_state[index] > 0:
  11.             dif = abs(lift_state[index] - 4)
  12.         else:
  13.             dif = waiting_people
  14.             the_lift_has_empty_slots = True
  15.         lift_state[index] += dif
  16.         waiting_people -= dif
  17. if the_lift_has_empty_slots:
  18.     print("The lift has empty spots!")
  19.     print(" ".join(map(str, lift_state)))
  20. else:
  21.     if waiting_people == 0:
  22.         print(" ".join(map(str, lift_state)))
  23.     else:
  24.         print(f"There isn't enough space! {waiting_people} people in a queue!")
  25.         print(" ".join(map(str, lift_state)))
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement