結果

問題 No.123 カードシャッフル
ユーザー lloyz
提出日時 2023-06-28 00:28:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 5,000 ms
コード長 395 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 89,088 KB
最終ジャッジ日時 2024-07-04 16:41:21
合計ジャッジ時間 1,955 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n, m = map(int, input().split())
A = list(map(int, input().split()))

B = deque([i + 1 for i in range(n)])
for i in range(m):
    a = A[i]
    C = deque()
    for j in range(a - 1):
        idx = B.popleft()
        C.append(idx)
    f = B.popleft()
    for _ in range(a - 1):
        idx = C.pop()
        B.appendleft(idx)
    B.appendleft(f)
print(B.popleft())
0