# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
875444 | imarn | Vudu (COCI15_vudu) | C++14 | 160 ms | 21124 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 ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define vi vector<int>
#define vpii vector<pii>
#define ll long long
using namespace std;
const int N=1e6+5;
ll a[N]{0};
ll cnt=0;
void dac(int l,int r){
if(l>=r)return;
int m=(l+r)>>1;
dac(l,m);dac(m+1,r);
int sz1=m-l+1,sz2=r-m;
ll le[sz1],re[sz2];
for(int i=0;i<sz1;i++)le[i]=a[i+l];
for(int i=0;i<sz2;i++)re[i]=a[m+1+i];
int li=0,ri=0,mi=l;
while(li<sz1&&ri<sz2){
if(le[li]<=re[ri])cnt+=sz2-ri,a[mi++]=le[li++];
else a[mi++]=re[ri++];
}while(li<sz1)a[mi++]=le[li++];
while(ri<sz2)a[mi++]=re[ri++];
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int n;cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
ll p;cin>>p;
for(int i=1;i<=n;i++)a[i]+=a[i-1]-p;
dac(0,n);cout<<cnt;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |