# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40838 | 2018-02-08T18:44:45 Z | Hassoony | Vudu (COCI15_vudu) | C++14 | 1000 ms | 65536 KB |
#include<bits/stdc++.h> #include<unordered_map> using namespace std; typedef long long ll; typedef double D; const ll inf=(1ll<<61); const int mod=1e9+7; const int MX=1e6+9; int n,bit[MX]; int a[MX]; ll p,prf[MX]; unordered_map<ll,int>has; vector<ll>hashy; void add(int x){ while(x<MX){ bit[x]++; x+=x&-x; } } int get(int x){ int ret=0; while(x){ ret+=bit[x]; x-=x&-x; } return ret; } int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); } ll sum=0; scanf("%lld",&p); for(int i=1;i<=n;i++){ prf[i]+=a[i]-p+prf[i-1]; hashy.push_back(prf[i]); } hashy.push_back(0); sort(hashy.begin(),hashy.end()); int tt=0; for(auto pp:hashy){ if(has[pp]==0)has[pp]=++tt; } add(has[0]); ll ans=0; int x; for(int i=1;i<=n;i++){ x=has[prf[i]]; ans+=get(x); add(x); } // cout<<endl; cout<<ans<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 760 KB | Output is correct |
2 | Correct | 4 ms | 768 KB | Output is correct |
3 | Correct | 4 ms | 872 KB | Output is correct |
4 | Execution timed out | 1076 ms | 65536 KB | Time limit exceeded |
5 | Correct | 700 ms | 65536 KB | Output is correct |
6 | Execution timed out | 1050 ms | 65536 KB | Time limit exceeded |
7 | Execution timed out | 1066 ms | 65536 KB | Time limit exceeded |
8 | Execution timed out | 1041 ms | 65536 KB | Time limit exceeded |
9 | Execution timed out | 1078 ms | 65536 KB | Time limit exceeded |
10 | Execution timed out | 1076 ms | 65536 KB | Time limit exceeded |