Submission #461345

#TimeUsernameProblemLanguageResultExecution timeMemory
461345Blobo2_Blobo2Vudu (COCI15_vudu)C++14
42 / 140
1028 ms65540 KiB
/* 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; set<long long>st; for(int i=0;i<n;i++){ c+=arr[i]; st.insert(c); } for(auto x:st) mp[x]=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)

vudu.cpp:19:24: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   19 | const int mo=1e9+7,INF=1e18;
      |                        ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...