結果

問題 No.2036 Max Middle
ユーザー shauuebbitshauuebbit
提出日時 2022-09-06 01:04:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 483 bytes
コンパイル時間 1,982 ms
コンパイル使用メモリ 200,224 KB
実行使用メモリ 6,472 KB
最終ジャッジ日時 2023-08-13 08:39:20
合計ジャッジ時間 4,056 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 45 ms
4,632 KB
testcase_09 AC 76 ms
6,088 KB
testcase_10 AC 80 ms
5,932 KB
testcase_11 AC 68 ms
6,316 KB
testcase_12 AC 58 ms
6,196 KB
testcase_13 AC 83 ms
6,268 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 85 ms
6,152 KB
testcase_17 AC 34 ms
5,936 KB
testcase_18 AC 57 ms
6,308 KB
testcase_19 AC 60 ms
5,960 KB
testcase_20 AC 66 ms
6,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    vector<long long> A(N), b(N - 1);
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];

        if (i) {
            if (A[i - 1] < A[i]) b[i - 1] = 1;
            else b[i - 1] = 0;
        }
    }

    long long ans = 0;
    int ones = 0;

    for (int i = 0; i < N - 1; i++) {
        if (b[i]) ++ones;
        else ans += ones;
    }

    cout << ans << endl;

    return 0;
}
0