#include <iostream>
#include <map>
#include <queue>
using namespace std;
map<int, queue<int> > Lu;
int a[100001], b[100001];
int main(){
int n;
while(cin >> n){
int x = n;
for(int i = 1; i <= n; i++){
cin >> a[i];
if(a[i] >= n){
i--;
n--;
}
}
for(int i = 1; i <= x; i++){
cin >> b[i];
if(b[i] >= x){
i--;
x--;
}
else
Lu[b[i]].push(i);
}
int num = 0, flag = 0;
for(int i = 1; i <= n; i++){
int log = Lu[a[i]].size();
while(log--){
int q = Lu[a[i]].front();
if(q/i*i != q || i/q*q != i){
num++;
Lu[a[i]].pop();
Lu[a[i]].push(q);
continue;
}
if(q == 1 && i == 1){
num++;
flag = 1;
Lu[a[i]].pop();
Lu[a[i]].push(q);
continue;
}
Lu[a[i]].pop();
Lu[a[i]].push(q);
}
}
cout << num << endl;
Lu.clear();
}
return 0;
}
1675序列变换
51nod没过的那题
最新推荐文章于 2022-08-13 00:19:16 发布