2023 rcpc

This commit is contained in:
2024-04-22 16:45:09 +03:00
parent a0ddb657b7
commit 156202ada0
61 changed files with 4462 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
/// Gheorghies Alexandru
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll NMAX=3e5+5,LGMAX=17;
ll v[NMAX];
map<ll,ll> fr,prv;
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,ans=0;
cin>>n;
for(ll i=1;i<=n;i++){
cin>>v[i];
v[i]=abs(v[i]);
++fr[v[i]];
if(fr[v[i]]%2) v[i]=-v[i];
}
for(ll i=1;i<=n;i++){
ans+=(i-prv[v[i]])*(n-i+1);
prv[v[i]]=i;
}
cout<<ans;
return 0;
}