程序:
var
n,i,m,tj,bz,w:longint;
a,b:array[0..100000]of longint;
procedure kp1(l,r:longint);
var
i,j,mid:longint;
begin
if l>=r then exit;
i:=l;j:=r;mid:=a[(l+r) div 2];
repeat
while a[i]>mid do inc(i);
while a[j]<mid do dec(j);
if i<=j then
begin
a[0]:=a[i];a[i]:=a[j];a[j]:=a[0];
inc(i);dec(j);
end;
until i>j;
kp1(l,j);
kp1(i,r);
end;
procedure kp2(l,r:longint);
var
i,j,mid:longint;
begin
if l>=r then exit;
i:=l;j:=r;mid:=b[(l+r) div 2];
repeat
while b[i]>mid do inc(i);
while b[j]<mid do dec(j);
if i<=j then
begin
b[0]:=b[i];b[i]:=b[j];b[j]:=b[0];
inc(i);dec(j);
end;
until i>j;
kp2(l,j);
kp2(i,r);
end;
begin
readln(n);
for i:=1 to n do
read(a[i]);
readln;
for i:=1 to n do
read(b[i]);
kp1(1,n);
kp2(1,n);
for i:=1 to n do
if b[i]<0 then
begin
w:=i;
break;
end;
m:=n;tj:=0;
for i:=1 to n do
begin
bz:=0;
if bz=0 then
if a[i]<0 then
if b[m]<0 then
begin
m:=w-1;
bz:=1;
end;
if bz=0 then
if a[i]>0 then
if b[m]<0 then
if abs(b[m])>a[i] then
begin
inc(tj);
dec(m);
bz:=1;
end;
if bz=0 then
if a[i]<0 then
if b[m]>0 then
if b[m]<abs(a[i]) then
begin
inc(tj);
dec(m);
bz:=1;
end;
if m=0 then break;
end;
write(tj);
end.