結果
問題 | No.2036 Max Middle |
ユーザー |
|
提出日時 | 2023-07-12 14:25:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 632 bytes |
コンパイル時間 | 698 ms |
コンパイル使用メモリ | 97,820 KB |
最終ジャッジ日時 | 2025-02-15 10:04:38 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
#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);//スワップ回数cnt++;}}cout<<ans<<endl;}