# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89963 | vex | Vudu (COCI15_vudu) | C++14 | 295 ms | 24072 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define maxn 1000005
#define plli pair<long long,long long>
using namespace std;
long long n;
plli a[maxn];
long long p;
long long tree[maxn]={0};
long long manji(long long x)
{
x--;
long long sol=0;
while(x>0)
{
sol+=tree[x];
x-=x&-x;
}
return sol;
}
void update(long long x)
{
while(x<=n)
{
tree[x]++;
x+=x&-x;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n;
a[0]={0,0};
for(int i=0;i<n;i++)
{
cin>>a[i+1].first;
a[i+1].first+=a[i].first;
a[i+1].second=i+1;
}
cin>>p;
for(int i=0;i<=n;i++)
{
a[i].first-=p*a[i].second;
}
sort(a,a+n+1);
long long sol=0;
for(int i=0;i<=n;i++)a[i].second++;
for(int i=0;i<=n;i++)
{
sol+=manji(a[i].second);
update(a[i].second);
}
cout<<sol<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |