結果

問題 No.123 カードシャッフル
ユーザー tnakao0123tnakao0123
提出日時 2016-03-20 23:09:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 825 bytes
コンパイル時間 985 ms
コンパイル使用メモリ 84,764 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 21:09:08
合計ジャッジ時間 1,430 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 WA -
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 17 ms
6,676 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 123.cc: No.123 カードシャッフル - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

/* global variables */

int cs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  cin >> n >> m;

  for (int i = 0; i < n; i++) cs[i] = i + 1;
  
  while (m--) {
    int ai;
    cin >> ai;
    ai--;

    int c = cs[ai];
    for (int i = ai - 1; i > 0; i--) cs[i] = cs[i - 1];
    cs[0] = c;
  }

  printf("%d\n", cs[0]);
  return 0;
}
0