Advertisement
Guest User

Untitled

a guest
Sep 17th, 2020
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1.  
  2. box_of_clothes = list(map(lambda x: int(x), input().split(' ')))
  3. capacity_of_rack = int(input())
  4. rack = 0
  5. number_of_racks_used = 1
  6.  
  7. while box_of_clothes:
  8. if rack + box_of_clothes[-1] < capacity_of_rack:
  9. rack += box_of_clothes.pop()
  10. elif rack + box_of_clothes[-1] == capacity_of_rack:
  11. rack += box_of_clothes.pop()
  12. rack = 0
  13. number_of_racks_used += 1
  14. else:
  15. number_of_racks_used += 1
  16. rack = 0
  17.  
  18. print(number_of_racks_used)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement