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 n;
int bit[1048577];
int num[1000001];
int idx[1000001];
void update(int idx){
while(idx<=1048576){
bit[idx]++;
idx+=(idx & -idx);
}
}
int sum(int idx){
int hap=0;
while(idx>0){
hap+=bit[idx];
idx-=(idx & -idx);
}
return hap;
}
int main(){
int i,ia;
long long int dap=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&ia);
num[ia]=i+1;
}
for(i=0;i<n;i++){
scanf("%d",&ia);
dap+=i-sum(num[ia]);
update(num[ia]);
}
printf("%lld",dap);
}
# | 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... |