#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
6944 KB |
Output is correct |
2 |
Correct |
0 ms |
6944 KB |
Output is correct |
3 |
Correct |
0 ms |
6944 KB |
Output is correct |
4 |
Correct |
0 ms |
6944 KB |
Output is correct |
5 |
Correct |
0 ms |
6944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
6944 KB |
Output is correct |
2 |
Correct |
0 ms |
6944 KB |
Output is correct |
3 |
Correct |
0 ms |
6944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
6944 KB |
Output is correct |
2 |
Correct |
0 ms |
6944 KB |
Output is correct |
3 |
Correct |
0 ms |
6944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
6944 KB |
Output is correct |
2 |
Correct |
48 ms |
6944 KB |
Output is correct |
3 |
Correct |
96 ms |
6944 KB |
Output is correct |
4 |
Correct |
136 ms |
6944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
181 ms |
6944 KB |
Output is correct |
2 |
Correct |
199 ms |
6944 KB |
Output is correct |
3 |
Correct |
210 ms |
6944 KB |
Output is correct |
4 |
Correct |
147 ms |
6944 KB |
Output is correct |
5 |
Correct |
240 ms |
6944 KB |
Output is correct |
6 |
Correct |
258 ms |
6944 KB |
Output is correct |