Advertisement
Nenogzar

Untitled

Jun 22nd, 2024
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. from collections import deque
  2.  
  3. packages = list(map(int, input().strip().split()))
  4. couriers = deque(map(int, input().strip().split()))
  5.  
  6. total_delivered_weight = 0
  7.  
  8. while packages and couriers:
  9. package_weight = packages.pop()
  10. courier_capacity = couriers.popleft()
  11.  
  12. if courier_capacity >= package_weight:
  13. courier_capacity -= 2 * package_weight
  14.  
  15. if courier_capacity > 0:
  16. couriers.appendleft(courier_capacity)
  17.  
  18. total_delivered_weight += package_weight
  19.  
  20. else:
  21.  
  22. package_weight -= courier_capacity
  23. packages.append(package_weight)
  24.  
  25. total_delivered_weight += courier_capacity
  26.  
  27. if not packages:
  28. print(f"Total weight: {total_delivered_weight} kg")
  29. print("Congratulations, all packages were delivered successfully by the couriers today.")
  30. elif not couriers:
  31. print(f"Total weight: {total_delivered_weight} kg")
  32. print("Unfortunately, there are no more available couriers to deliver the following packages:", end=" ")
  33. print(", ".join(map(str, packages)))
  34. else:
  35. print(f"Total weight: {total_delivered_weight} kg")
  36. print("Couriers are still on duty:", end=" ")
  37. print(", ".join(map(str, couriers)), end="")
  38. print(" but there are no more packages to deliver.")
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement