結果
問題 | No.123 カードシャッフル |
ユーザー |
|
提出日時 | 2020-04-08 11:43:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 5,000 ms |
コード長 | 503 bytes |
コンパイル時間 | 667 ms |
コンパイル使用メモリ | 74,216 KB |
最終ジャッジ日時 | 2025-01-09 15:08:39 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
ソースコード
#include <iostream>#include <numeric>#include <vector>void solve() {int n, q;std::cin >> n >> q;std::vector<int> xs(n);std::iota(xs.begin(), xs.end(), 1);while (q--) {int x;std::cin >> x;--x;int t = xs[x];xs.erase(xs.begin() + x);xs.insert(xs.begin(), t);}std::cout << xs.front() << std::endl;}int main() {std::cin.tie(nullptr);std::ios::sync_with_stdio(false);solve();return 0;}