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 p[1000001];
int BIT[500001];
void update(int x){while(x<=500000){BIT[x]++;x+=x&-x;}}
int sum(int x){int y=0;while(x){y+=BIT[x];x-=x&-x;}return y;}
int main()
{
long long r=0;
int i,n,t;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&t);
p[t]=i;
}
for(i=1;i<=n;i++)
{
scanf("%d",&t);
update(p[t]);
r+=i-sum(p[t]);
}
printf("%lld",r);
}
# | 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... |