Skip to content

Commit 1a86117

Browse files
committed
[BOJ] #2164.카드2 / 실버4 / 15분(∆)
1 parent e414c4a commit 1a86117

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import sys
2-
input = sys.stdin.read
2+
input = sys.stdin.readline
3+
from collections import deque
34

45
N = int(input())
5-
L = list(range(1,N+1))
6+
cards = deque(range(1, N + 1)) # 1부터 N까지의 숫자를 덱에 저장
67

7-
while (len(L)>1):
8-
L.pop(0)
9-
temp = L.pop(0)
10-
L.append(temp)
8+
while len(cards) > 1:
9+
cards.popleft() # 제일 위의 카드를 버림
10+
cards.append(cards.popleft()) # 그다음 카드를 아래로 옮김
1111

12-
print(L.pop(0))
12+
print(cards[0]) # 마지막으로 남은 카드 출력

0 commit comments

Comments
 (0)