# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
461346 | Blobo2_Blobo2 | Vudu (COCI15_vudu) | C++14 | 993 ms | 65540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
Editor: Abdelrahman Hossam
Nickname: Blobo2_Blobo2
IOI next year isA :)
*/
/*#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")*/
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define gen(arr,n,nxt) generate(arr,arr+n,nxt)
#define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0);
const int mo=1e9+7,INF=1e18;
int nxt(){int x;cin>>x;return x;}
long long tree[4000005];
int arr[1000000],n,p;
void update(int pos,int val,int idx=1,int ss=0,int se=n-1){
if(ss==se){
tree[idx]+=val;
return;
}
int mid=(ss+se)>>1;
if(pos<=mid)update(pos,val,idx<<1,ss,mid);
else update(pos,val,idx<<1|1,mid+1,se);
tree[idx] = tree[idx<<1]+tree[idx<<1|1];
}
int sum(int l,int r,int idx=1,int ss=0,int se=n-1){
if(l>se||r<ss)
return 0;
if(l<=ss&&se<=r)
return tree[idx];
int mid=(ss+se)>>1;
return sum(l,r,idx<<1,ss,mid)+
sum(l,r,idx<<1|1,mid+1,se);
}
signed main(){
Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty
n=nxt();
gen(arr,n,nxt);
p=nxt();
for(int i=0;i<n;i++)arr[i]-=p;
int c=0,idx=1;
unordered_map<long long,int>mp;
for(int i=0;i<n;i++){
c+=arr[i];
mp[c]=1;
}
for(auto x:mp)
mp[x.first]=idx++;
long long cnt=0,ans=0;
for(int i=0;i<n;i++){
cnt+=arr[i];
ans+=sum(1,mp[cnt]);
update(mp[cnt],1);
if(cnt>=0)ans++;
}
cout<<ans;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |