結果

問題 No.123 カードシャッフル
ユーザー fal_rnd
提出日時 2017-02-04 19:46:41
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 507 bytes
コンパイル時間 1,519 ms
コンパイル使用メモリ 159,344 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 06:18:04
合計ジャッジ時間 2,018 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

const char en = '\n';
using  ll =          long long;
using ull = unsigned long long;

int main() {
	cin.tie();	ios::sync_with_stdio(false);

	int n,m;
	cin>>n>>m;

	list<int> l;
	for(int i=1;i<=n;i++) l.push_back(i);


	list<int>::iterator it;
	int v;
	for(int i=0;i<m;i++){
		cin>>v;
		it=l.begin();
		advance(it,v-1);
		l.splice(l.begin(),l,it);
	}

	cout<<l.front()<<en;
	/*
	while(!l.empty()){
		cout<<l.front()<<en;
		l.pop_front();
	}
	*/
	return 0;
}
0