๋ฌธ์
https://www.acmicpc.net/problem/2346
ํ์ด
# ๋ฐฑ์ค 2346๋ฒ ๋ฌธ์ - ํ์ ํฐ๋จ๋ฆฌ๊ธฐ
import sys
from collections import deque
input = sys.stdin.readline
n = int(input())
q = deque(enumerate(map(int, input().split())))
answer = []
while q:
idx, paper = q.popleft()
answer.append(idx + 1)
if paper > 0:
q.rotate(-(paper - 1))
elif paper < 0:
q.rotate(-paper)
print(' '.join(map(str, answer)))
deque.rotate๋ฅผ ์ด์ฉํด ํ ์ ์๋ ๋ฌธ์ ์ด๋ค.
'๐๏ธ Algorithm > ๐ฉ ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ฉ [๋ฐฑ์ค] [Python] [Silver2] 3085๋ฒ_์ฌํ ๊ฒ์ (0) | 2023.06.14 |
---|---|
๐ฉ [๋ฐฑ์ค] [Python] [Silver3] 15903๋ฒ_์นด๋ ํฉ์ฒด ๋์ด (0) | 2023.05.29 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold4] 1339๋ฒ_๋จ์ด ์ํ (0) | 2023.05.15 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold5] 13219๋ฒ_Trains (0) | 2023.05.14 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold2] 12015๋ฒ_๊ฐ์ฅ ๊ธด ์ฆ๊ฐํ๋ ๋ถ๋ถ ์์ด 2 (0) | 2023.05.12 |