結果

問題 No.123 カードシャッフル
ユーザー kichirb3kichirb3
提出日時 2018-03-05 20:15:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 658 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 10,668 KB
実行使用メモリ 16,112 KB
最終ジャッジ日時 2023-10-11 15:41:49
合計ジャッジ時間 1,320 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,784 KB
testcase_01 AC 15 ms
7,840 KB
testcase_02 AC 16 ms
7,708 KB
testcase_03 AC 15 ms
7,784 KB
testcase_04 AC 16 ms
7,756 KB
testcase_05 AC 16 ms
7,908 KB
testcase_06 AC 16 ms
7,768 KB
testcase_07 AC 15 ms
7,840 KB
testcase_08 AC 15 ms
7,812 KB
testcase_09 AC 15 ms
7,844 KB
testcase_10 AC 47 ms
9,868 KB
testcase_11 AC 52 ms
16,112 KB
testcase_12 AC 55 ms
15,148 KB
testcase_13 AC 53 ms
15,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
"""
No.123 カードシャッフル
https://yukicoder.me/problems/no/123

"""
import sys
from sys import stdin
input = stdin.readline


def do_shuffle(deck, shuffles):
    for s in shuffles:
        top = deck.pop(s-1)     # 上からs枚目を抜いて
        deck.insert(0, top)     # 一番上に積む


def main(args):
    N, M = map(int, input().split())
    shuffles = [int(x) for x in input().split()]
    
    deck = list(range(1, N+1))  # カードを用意
    do_shuffle(deck, shuffles)  # シャッフル
    print(deck[0])              # 1番上のカードの番号


if __name__ == '__main__':
    main(sys.argv[1:])
0