南宁经典网站建设/太原搜索引擎优化
题目大意:一串数,每次把最后那个数挪到前面任意位置,就最少挪动次数
显然一个数最多挪一次(只能从后取的话,插2次的一定能变成1次)
因此找最后挪动的数即可,最后挪动的数即由于与下序列的连线与之前的交叉,其它数无论怎么挪都无法影响到它)
Program DD;
constmaxn=200000;
varn,i,j,l,r:longint;a,b,hposa,hposb:array[1..maxn] of longint;
beginread(n);for i:=1 to n dobeginread(a[i]);hposa[a[i]]:=i;end;for i:=1 to n dobeginread(b[i]);hposb[b[i]]:=i;end;r:=0;for i:=1 to n dobeginif r<hposb[a[i]] then r:=hposb[a[i]]else break;end;if (r=hposb[a[i]]) then writeln('0') elsewriteln(n-i+1);end.