# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167731 | 2019-12-09T20:44:07 Z | rzbt | Vudu (COCI15_vudu) | C++14 | 679 ms | 65540 KB |
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 1000005 typedef long long ll; using namespace std; ll n,p,res; ll niz[MAXN]; ll bit[MAXN]; void update(ll p,ll x){ for(;p<MAXN;p+=(p&(-p))) bit[p]+=x; } ll dobij(ll p){ ll z=0; for(;p>0;p-=(p&(-p))) z+=bit[p]; return z; } vector<ll> s; map<ll,ll> m; int main() { scanf("%lld", &n); for(ll i=1;i<=n;i++) scanf("%lld",niz+i); ll tzbir=0; scanf("%lld",&p); for(ll i=1;i<=n;i++){ tzbir+=niz[i]-p; s.pb(tzbir); } sort(all(s)); s.erase(unique(all(s)),s.end()); ll tbr=0; for(auto x:s){ tbr++; m[x]=tbr; } tzbir=0; for(ll i=1;i<=n;i++){ tzbir+=niz[i]-p; if(tzbir>=0)res++; ll t=m[tzbir]; res+=dobij(t); update(t,1); } printf("%lld",res); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1016 KB | Output is correct |
2 | Correct | 5 ms | 888 KB | Output is correct |
3 | Correct | 5 ms | 888 KB | Output is correct |
4 | Runtime error | 607 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
5 | Correct | 679 ms | 52716 KB | Output is correct |
6 | Runtime error | 583 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
7 | Runtime error | 573 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
8 | Runtime error | 633 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
9 | Runtime error | 603 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
10 | Runtime error | 598 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |