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 <cstdio>
int a[1000010],bit[500010];
long long int s;
int getsum(int k){
int sum=0;
while(k){
sum+=bit[k];
k-=k&-k;
}
return sum;
}
void update(int k,int e,int v){
while(k<=e){
bit[k]+=v;
k+=k&-k;
}
}
int main(){
int i,n,k;
scanf("%d",&n);
for(i=1;i<=n;++i)scanf("%d",&k),a[k]=i;
for(i=1;i<=n;++i){
scanf("%d",&k);
update(a[k],n,1);
s+=getsum(n)-getsum(a[k]);
}
printf("%lld",s);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |