結果
| 問題 | No.123 カードシャッフル | 
| コンテスト | |
| ユーザー |  hotpepsi | 
| 提出日時 | 2015-01-11 23:32:08 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 23 ms / 5,000 ms | 
| コード長 | 587 bytes | 
| コンパイル時間 | 489 ms | 
| コンパイル使用メモリ | 63,652 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-13 04:11:30 | 
| 合計ジャッジ時間 | 1,225 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 10 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <sstream>
#include <list>
using namespace std;
int main(int argc, char *argv[])
{
	int N, M;
	string s;
	{
		getline(cin, s);
		stringstream ss(s);
		ss >> N >> M;
	}
	list<int> l;
	for (int i = 0; i < N; ++i) {
		l.push_back(i + 1);
	}
	{
		getline(cin, s);
		stringstream ss(s);
		for (int i = 0; i < M; ++i) {
			int pos;
			ss >> pos;
			list<int>::const_iterator it = l.begin();
			for (int j = 1; j < pos; ++j) {
				++it;
			}
			int a = *it;
			l.erase(it);
			l.push_front(a);
		}
		cout << l.front() << endl;
	}
	return 0;
}
            
            
            
        