結果

問題 No.2036 Max Middle
ユーザー HIcoderHIcoder
提出日時 2023-07-12 14:33:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 755 bytes
コンパイル時間 1,239 ms
コンパイル使用メモリ 100,520 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 04:51:47
合計ジャッジ時間 3,197 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,356 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 43 ms
4,352 KB
testcase_09 AC 73 ms
4,348 KB
testcase_10 AC 76 ms
4,352 KB
testcase_11 AC 64 ms
4,352 KB
testcase_12 AC 55 ms
4,352 KB
testcase_13 AC 79 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 81 ms
4,348 KB
testcase_17 AC 31 ms
4,348 KB
testcase_18 AC 54 ms
4,348 KB
testcase_19 AC 57 ms
4,348 KB
testcase_20 AC 63 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
const double PI=acos(-1);


int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    ll ans=0;
    int cnt=0;
    for(int i=0;i+1<N;i++){
        if(A[i]>A[i+1]){
            ans+=1LL*(i-cnt);
            //スワップ回数. 
            //i=0,1,2..,と行い,左からみてきたもののうちの<の数をカウントしている
            cnt++;
        }
    }

    cout<<ans<<endl;


}
0