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