Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
36162 | j136 | 【S】T2 | C++ | 解答错误 | 35 | 72 MS | 468 KB | 436 | 2025-02-07 20:24:31 |
#include<bits/stdc++.h> using namespace std; int n,p[11451],cnt[2][22902],ans,x; int main(){ cin>>n; for(int i=1;i<=n;i++)cin>>p[i]; for(int i=1;i<=n;i++){ memset(cnt,0,sizeof cnt),x=0; for(int j=i;j>0;j--)x+=(p[j]>p[i])-(p[j]<p[i]),cnt[j&1][x+1145]+=j; x=0; for(int j=i;j<=n;j++)x+=(p[j]<p[i])-(p[j]>p[i]),ans+=1ll*cnt[j&1][x+1145]*p[i]*j; } cout<<ans; return 0; }