結果

問題 No.123 カードシャッフル
ユーザー tenkyu9
提出日時 2018-03-09 00:48:09
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 492 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 83,084 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-05 08:19:54
合計ジャッジ時間 3,080 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 4
other RE * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:18: warning: ‘m’ is used uninitialized [-Wuninitialized]
   17 |   vector<int> a(m);
      |                  ^
main.cpp:16:10: note: ‘m’ declared here
   16 |   int n, m;
      |          ^

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

  int n, m;
  vector<int> a(m);
  cin >> n >> m;
  for(int i=0; i<m; i++){
    cin >> a[i];
  }
  int pos=1;
  for(int i=m-1; 0<=i; i--){
    if(pos==1){
      pos=a[i];
    } else if(a[i]>=pos){
      pos--;
    }
  }
  cout << pos << endl;
  
  return 0;
}
0