結果

問題 No.123 カードシャッフル
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-07-29 21:31:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 345 bytes
コンパイル時間 1,964 ms
コンパイル使用メモリ 193,128 KB
最終ジャッジ日時 2025-01-07 09:59:54
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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