Pagini recente » Cod sursa (job #1340861) | Cod sursa (job #31266) | Cod sursa (job #3211929) | Cod sursa (job #2879524) | Cod sursa (job #1356435)
program mire;
var f,g:text;
poza,t,b,tt:array[1..30000] of integer;
n,c,i,j,x:integer;
procedure citire;
var i,x:integer;
begin
assign(f,'tabara1.in'); reset(f);
readln(f,n);
for i:=1 to n do
begin
read(f,x);
poza[x]:=i;
end;
readln(f);
for i:=1 to n do
begin
read(f,x);
t[i]:=poza[x];
end;
close(f);
end;
function max(a,b:longint):longint;
begin
if a>b then
max:=a
else
max:=b;
end;
function cauta(xx,st,dr:longint):longint;
var m:longint;
begin
while st<=dr do
begin
m:=(st+dr) div 2;
if xx<=b[m] then dr:=m-1 else
st:=m+1;
end;
cauta:=st;
end;
begin
citire;
assign(g,'tabara1.out'); rewrite(g);
b[1]:=t[1]; x:=1; tt[1]:=1;
for i:=2 to n do
begin
j:=cauta(t[i],1,x);
b[j]:=t[i];
tt[i]:=j;
x:=max(x,j);
end;
writeln(g,x);
close(g);
end.