Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- waves = int(input())
- plates = deque([int(x) for x in input().split(' ')])
- warriors = []
- for i in range(1, waves + 1):
- power = input().split(' ')
- if plates:
- [warriors.append(int(x)) for x in power]
- if i % 3 == 0:
- new_plate = int(input())
- plates.append(new_plate)
- while True:
- if not warriors or not plates:
- break
- current_plate = plates.popleft()
- while current_plate > 0:
- if warriors:
- current_warrior = warriors.pop()
- else:
- plates.appendleft(current_plate)
- break
- if current_plate > current_warrior:
- current_plate -= current_warrior
- elif current_plate < current_warrior:
- current_plate -= current_warrior
- warriors.append(abs(current_plate))
- else:
- current_plate -= current_warrior
- if not plates:
- print('The Trojans successfully destroyed the Spartan defense.')
- if warriors:
- print(f"Warriors left: {', '.join(map(str, reversed(warriors)))}")
- else:
- print('The Spartans successfully repulsed the Trojan attack.')
- print(f"Plates left: {', '.join(map(str, plates))}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement