Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- elfs = deque([int(x) for x in input().split()]) # [10 16 13 25]
- materials = deque(int(x) for x in input().split()) # [12 11 8]
- total_energy = 0
- total_toys = 0
- number_of_tries = 0 # number_of_tries
- while elfs and materials:
- elf = elfs.popleft()
- material = materials[-1]
- if elf < 5:
- continue
- number_of_tries += 1
- current_toys_count = 0
- if number_of_tries % 3 == 0:
- material *= 2
- current_toys_count += 1
- if elf >= material:
- total_energy += material
- elf -= material
- if number_of_tries % 5 != 0:
- elf += 1
- current_toys_count += 1
- else:
- current_toys_count = 0 # нулираме играчката
- materials.pop()
- else:
- elf *= 2
- current_toys_count = 0
- total_toys += current_toys_count
- elfs.append(elf)
- print(f"Toys: {total_toys}")
- print(f"Energy: {total_energy}")
- if elfs:
- print(f"Elves left: {', '.join(str(x) for x in elfs)}")
- if materials:
- print(f"Boxes left: {', '.join(str(x) for x in materials)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement