結果
| 問題 |
No.2036 Max Middle
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-12 23:08:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 367 bytes |
| コンパイル時間 | 2,186 ms |
| コンパイル使用メモリ | 195,068 KB |
| 最終ジャッジ日時 | 2025-01-30 21:43:49 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin>>N;
vector<int>A(N);
for(int &i:A)cin>>i;
long long ans=0,u=0,d=0;
for(int i=0;i<N-1;i++){
if(A[i+1]>A[i]){
if(d!=0){
ans+=u*d,d=0;
}
u+=1;
}else{
d+=1;
}
}
ans+=u*d;
cout<<ans<<'\n';
}