結果

問題 No.123 カードシャッフル
ユーザー chacoder1
提出日時 2021-04-08 21:31:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 392 bytes
コンパイル時間 4,228 ms
コンパイル使用メモリ 191,704 KB
最終ジャッジ日時 2025-01-20 13:09:25
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
  
int main(){
  int n,m;
  cin>>n>>m;
  int a[n];
  rep(i,n)a[i]=i+1;
  int temp=0;
  int res=0;
  rep(i,m){
    cin>>temp;
    temp--;
    if(temp==0) continue;
    res=a[temp];
    for(int j=temp;j>0;j--){
      a[j]=a[j-1];
    }
    a[0]=res;
  }
  cout<<a[0]<<endl;
  return 0;
}
0