結果

問題 No.123 カードシャッフル
ユーザー cww
提出日時 2016-09-30 23:55:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 518 bytes
コンパイル時間 1,666 ms
コンパイル使用メモリ 171,580 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-21 11:18:01
合計ジャッジ時間 2,345 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	vector<int> A( M );
	for( auto&& x : A )
	{
		cin >> x;
	}
	vector<int> num;
	REP( i, N )
	{
		num.push_back( i + 1 );
	}
	REP( i, M )
	{
		//Ai番目の数字を先頭に置く
		num.insert( num.begin(), num[ A[ i ] - 1 ] );
		//Ai番目にあった数字を削除
		num.erase( num.begin() + A[ i ] );
	}
	cout << num[ 0 ] << endl;
	return 0;
}
0