-Code
from collections import deque
for t in range(1, int(input()) + 1):
n = int(input())
nums = deque(list(map(int, input().split())))
while len(nums) != 2:
temp = deque()
while nums:
front = nums.popleft()
if nums:
back = nums.pop()
temp.append(front + back)
else:
temp.append(front * 2)
nums = temp
res = "Alice" if nums[0] > nums[1] else "Bob"
print(f"Case #{t}: {res}")
큐로 꺼내는 과정에서 한번에 front와 back을 한번에 뽑아 계산하는 방법을 사용해서 여러번 틀렸었습니다.
'Beakjoon&프로그래머스 > 파이썬' 카테고리의 다른 글
[백준/파이썬] 8574번 Ratownik (0) | 2024.06.09 |
---|---|
[백준/파이썬] 14911번 궁합 쌍 찾기 (0) | 2024.06.08 |
[백준/파이썬] 30315번 King's Keep (1) | 2024.06.06 |
[백준/파이썬] 6139번 Speed Reading (0) | 2024.06.05 |
[백준/파이썬] 30700번 KOREA 문자열 만들기 (0) | 2024.06.04 |