# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
219214 |
2020-04-04T15:29:12 Z |
DavidDamian |
Vudu (COCI15_vudu) |
C++11 |
|
827 ms |
65540 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int bit[1000006];
int n;
void update(int i,int v)
{
while(i<=n+5){
bit[i]+=v;
i+=(i&(-i));
}
}
int query(int i)
{
int ans=0;
while(i>0){
ans+=bit[i];
i-=(i&(-i));
}
return ans;
}
ll getSum(int a,int b)
{
ll ans=(ll)query(b)-(ll)query(a-1);
return ans;
}
typedef pair<ll,int> pii;
map<ll,int> remap;
ll k;
ll A[1000006]; //S[i]-k*i
//ll S_K[1000006];
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>A[i];
A[i]+=A[i-1];
}
cin>>k;
remap[0]=1;
for(ll i=1;i<=n;i++){
A[i]=A[i]-k*i; //S_K[i]=A[i]-k*i
remap[ A[i] ]=1;
}
int id=1;
for(pii p: remap){
remap[p.first]=id++;
}
for(int i=0;i<=n;i++){
A[i]=remap[ A[i] ];
}
remap.clear();
ll total=0;
for(int i=0;i<=n;i++){
if(i>0) total+=(ll)getSum(1,A[i]);
update(A[i],1);
}
cout<<total<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
896 KB |
Output is correct |
2 |
Correct |
7 ms |
768 KB |
Output is correct |
3 |
Correct |
7 ms |
640 KB |
Output is correct |
4 |
Runtime error |
506 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Correct |
487 ms |
40952 KB |
Output is correct |
6 |
Correct |
827 ms |
65536 KB |
Output is correct |
7 |
Runtime error |
779 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Correct |
735 ms |
57776 KB |
Output is correct |
9 |
Runtime error |
419 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Correct |
790 ms |
65536 KB |
Output is correct |