結果

問題 No.123 カードシャッフル
ユーザー lloyzlloyz
提出日時 2023-06-28 00:28:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 230 ms / 5,000 ms
コード長 395 bytes
コンパイル時間 1,505 ms
コンパイル使用メモリ 86,856 KB
実行使用メモリ 93,192 KB
最終ジャッジ日時 2023-09-17 23:15:39
合計ジャッジ時間 3,647 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,664 KB
testcase_01 AC 95 ms
71,560 KB
testcase_02 AC 94 ms
71,560 KB
testcase_03 AC 94 ms
71,668 KB
testcase_04 AC 94 ms
71,556 KB
testcase_05 AC 94 ms
71,508 KB
testcase_06 AC 95 ms
71,712 KB
testcase_07 AC 95 ms
71,564 KB
testcase_08 AC 95 ms
71,508 KB
testcase_09 AC 95 ms
71,576 KB
testcase_10 AC 131 ms
92,744 KB
testcase_11 AC 230 ms
92,972 KB
testcase_12 AC 193 ms
93,112 KB
testcase_13 AC 195 ms
93,192 KB
権限があれば一括ダウンロードができます

ソースコード

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