結果

問題 No.365 ジェンガソート
ユーザー Akidai16
提出日時 2020-03-29 11:51:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 1,587 ms
コンパイル使用メモリ 161,112 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-02 13:15:45
合計ジャッジ時間 3,567 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

int main() {
    int N;
    cin>>N;
    vector<int> A(N, 0);
    REP(i, 0, N) cin>>A[i];
    int Amax = N; int count = 0;
    for(int i=N-1; i >= 0; i--){
        if(A[i] == Amax){
            Amax--;
            count++;
        }
    }
    cout << N-count << endl;
}
0