結果

問題 No.365 ジェンガソート
ユーザー sumomoneko
提出日時 2018-07-04 13:23:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 927 bytes
コンパイル時間 1,503 ms
コンパイル使用メモリ 169,948 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-01 02:09:49
合計ジャッジ時間 3,272 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)


using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    std::reverse(std::begin(A), std::end(A));

    int64_t v = N;
    int64_t count = 0;
    for (auto a: A) {
        if (a == v) {
            v--;
        }
        else {
            count++;
        }
    }

    std::cout << count << std::endl;

    return 0;
}
0