Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- materials = list(map(int, input().split()))
- magic_levels = deque(map(int, input().split()))
- presents = {
- "Gemstone": [100, 199],
- "Porcelain Sculpture": [200, 299],
- "Gold": [300, 399],
- "Diamond Jewellery": [400, 499],
- }
- items = {}
- def sum_item(material, magic):
- return material + magic
- def check_dict(result):
- for key, value in presents.items():
- start, end = value
- if result in range(start, end + 1):
- if key not in items:
- items[key] = 1
- else:
- items[key] += 1
- return True
- while materials and magic_levels:
- material = materials.pop()
- magic = magic_levels.popleft()
- result = sum_item(material, magic)
- if not check_dict(result):
- if result < 100:
- if result % 2 == 0:
- material *= 2
- magic *= 3
- result = sum_item(material, magic)
- check_dict(result)
- else:
- result *= 2
- check_dict(result)
- elif result > 499:
- result //= 2
- check_dict(result)
- crafted_presents = True
- for present in presents.keys():
- if present not in items:
- crafted_presents = False
- break
- if crafted_presents:
- print("The wedding presents are made!")
- else:
- print("Aladdin does not have enough wedding presents.")
- if materials:
- print(f"Materials left: {', '.join(map(str, materials))}")
- if magic_levels:
- print(f"Magic left: {', '.join(map(str, magic_levels))}")
- for key in sorted(items):
- print(f"{key}: {items[key]}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement