Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- packages = list(map(int, input().strip().split()))
- couriers = deque(map(int, input().strip().split()))
- total_delivered_weight = 0
- while packages and couriers:
- package_weight = packages.pop()
- courier_capacity = couriers.popleft()
- if courier_capacity >= package_weight:
- courier_capacity -= 2 * package_weight
- if courier_capacity > 0:
- couriers.appendleft(courier_capacity)
- total_delivered_weight += package_weight
- else:
- package_weight -= courier_capacity
- packages.append(package_weight)
- total_delivered_weight += courier_capacity
- if not packages:
- print(f"Total weight: {total_delivered_weight} kg")
- print("Congratulations, all packages were delivered successfully by the couriers today.")
- elif not couriers:
- print(f"Total weight: {total_delivered_weight} kg")
- print("Unfortunately, there are no more available couriers to deliver the following packages:", end=" ")
- print(", ".join(map(str, packages)))
- else:
- print(f"Total weight: {total_delivered_weight} kg")
- print("Couriers are still on duty:", end=" ")
- print(", ".join(map(str, couriers)), end="")
- print(" but there are no more packages to deliver.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement