結果
| 問題 |
No.123 カードシャッフル
|
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2015-01-11 23:32:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 5,000 ms |
| コード長 | 581 bytes |
| コンパイル時間 | 489 ms |
| コンパイル使用メモリ | 64,160 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-13 04:11:33 |
| 合計ジャッジ時間 | 1,177 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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>::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;
}
hotpepsi