# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
762756 |
2023-06-21T17:31:08 Z |
ETheBest3 |
Vudu (COCI15_vudu) |
C++14 |
|
768 ms |
65536 KB |
#include<bits/stdc++.h>
#define endl "\n"
#define lli int
using namespace std;
const lli MAXN=1000005;
lli N, a[MAXN], P, tree[MAXN];
long long pref[MAXN], ss[MAXN], ans;
unordered_map<long long, lli> m;
void update(lli i, lli d){
while(i<=N+1){
tree[i]+=d;
i+=i&(-i);
}
return;
}
long long query(lli i){
long long otg=0;
while(i>0){
otg+=tree[i];
i-=i&(-i);
}
return otg;
}
int main() {
ios_base::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
cin>>N;
for(lli i=1; i<=N; i++){
cin>>a[i];
}
cin>>P;
for(lli i=1; i<=N; i++){
a[i]-=P;
pref[i]=pref[i-1]+a[i];
ss[i]=pref[i];
}
sort(ss, ss+N+1);
lli k=1;
for(lli i=0; i<=N; i++){
if(i!=0 and ss[i]==ss[i-1])continue;
m[ss[i]]=k;
k++;
}
update(m[0], 1);
for(lli i=1; i<=N; i++){
ans+=query(m[pref[i]]);
update(m[pref[i]], 1);
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
724 KB |
Output is correct |
2 |
Correct |
3 ms |
724 KB |
Output is correct |
3 |
Correct |
2 ms |
664 KB |
Output is correct |
4 |
Correct |
768 ms |
64468 KB |
Output is correct |
5 |
Correct |
365 ms |
35888 KB |
Output is correct |
6 |
Correct |
650 ms |
58464 KB |
Output is correct |
7 |
Correct |
672 ms |
60516 KB |
Output is correct |
8 |
Correct |
617 ms |
54600 KB |
Output is correct |
9 |
Runtime error |
583 ms |
65536 KB |
Execution killed with signal 9 |
10 |
Correct |
654 ms |
59080 KB |
Output is correct |