結果

問題 No.2036 Max Middle
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-05-11 01:03:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 998 ms
コンパイル使用メモリ 107,804 KB
実行使用メモリ 5,152 KB
最終ジャッジ日時 2023-08-18 02:02:46
合計ジャッジ時間 3,941 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 46 ms
4,376 KB
testcase_09 AC 77 ms
4,984 KB
testcase_10 AC 81 ms
4,932 KB
testcase_11 AC 68 ms
5,044 KB
testcase_12 AC 58 ms
5,104 KB
testcase_13 AC 83 ms
4,988 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 85 ms
5,016 KB
testcase_17 AC 34 ms
4,880 KB
testcase_18 AC 56 ms
5,152 KB
testcase_19 AC 60 ms
4,900 KB
testcase_20 AC 67 ms
5,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    ll N, ans=0, cnt=0;
    cin >> N;
    vector<ll> A(N);
    string S = "";
    for (int i=0; i<N; i++) cin >> A[i];
    for (int i=0; i<N-1; i++){
        if (A[i] < A[i+1]) S += '<';
        else S += '>';
    }

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

    cout << ans << endl;
    
    return 0;
}
0