結果
| 問題 |
No.2036 Max Middle
|
| コンテスト | |
| ユーザー |
たたき@競プロ
|
| 提出日時 | 2023-07-09 08:52:53 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 91 ms / 2,000 ms |
| コード長 | 575 bytes |
| コンパイル時間 | 2,847 ms |
| コンパイル使用メモリ | 245,412 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-23 05:35:01 |
| 合計ジャッジ時間 | 5,342 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pp=pair<int,int>;
#define sr string
#define vc vector
#define db double
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
int n;cin>>n;
vc<int>v(n); rep(i,n)cin>>v[i];
vc<int>x(n-1);
rep(i,n-1){
if(v[i]<v[i+1])x[i]=1;
else x[i]=0;
}
ll s=0;rep(i,n-1)s+=x[i];
ll ans=0;
rep(i,n-1)if(x[i]==1)ans+=n-2-i;
ans-=s*(s-1)/2;
cout<<ans;
}
たたき@競プロ