#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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
6948 KB |
Output is correct |
2 |
Correct |
0 ms |
6948 KB |
Output is correct |
3 |
Correct |
0 ms |
6948 KB |
Output is correct |
4 |
Correct |
0 ms |
6948 KB |
Output is correct |
5 |
Correct |
0 ms |
6948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
6948 KB |
Output is correct |
2 |
Correct |
4 ms |
6948 KB |
Output is correct |
3 |
Correct |
8 ms |
6948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
6948 KB |
Output is correct |
2 |
Correct |
24 ms |
6948 KB |
Output is correct |
3 |
Correct |
24 ms |
6948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
6948 KB |
Output is correct |
2 |
Correct |
76 ms |
6948 KB |
Output is correct |
3 |
Correct |
100 ms |
6948 KB |
Output is correct |
4 |
Correct |
152 ms |
6948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
184 ms |
6948 KB |
Output is correct |
2 |
Correct |
228 ms |
6948 KB |
Output is correct |
3 |
Correct |
208 ms |
6948 KB |
Output is correct |
4 |
Correct |
240 ms |
6948 KB |
Output is correct |
5 |
Correct |
244 ms |
6948 KB |
Output is correct |
6 |
Correct |
244 ms |
6948 KB |
Output is correct |