結果

問題 No.123 カードシャッフル
ユーザー lunnear
提出日時 2018-12-12 12:20:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 542 bytes
コンパイル時間 548 ms
コンパイル使用メモリ 58,488 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-25 03:32:01
合計ジャッジ時間 1,340 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <list>

int main()
{
    int n ,m;
    std::cin >> n >> m;
    
    std::list<char> c;
    for(int i = 0; i < n; i++)
    {
        c.push_back(i + 1);
    }
    

    for(int i = 0; i < m; i++)
    {
        int a;
        std::cin >> a;
        
        auto iter = c.begin();
        iter--;
        for(int j = 0; j < a; j++)
            iter++;
        
        char w = (*iter);
        c.remove(w);
        c.push_front(w);
    }
    
    
    std::cout << (int)c.front() << std::endl;
    
    return 0;
}
0