結果

問題 No.123 カードシャッフル
ユーザー arrowsarrows
提出日時 2017-01-21 23:00:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 532 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 66,648 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 19:53:17
合計ジャッジ時間 1,329 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 18 ms
4,376 KB
testcase_11 AC 33 ms
4,380 KB
testcase_12 AC 30 ms
4,376 KB
testcase_13 AC 29 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <list>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    list<int> lst;
    for (int i = 0; i < N; i++) {
        lst.push_back(i + 1);
    }
    for (int i = 0; i < M; i++) {
        int c, n = 0;
        cin >> c;
        for (auto it = lst.begin(); it != lst.end(); ++it) {
            int num = *it;
            if (++n == c) {
                lst.erase(it);
                lst.push_front(num);
            }
        }
    }
    cout << *lst.begin() << endl;
    return 0;
}
0