type
datetype=record
con,vol:longint;
end;
arr=array [0..50] of datetype;
var
date:arr;
i,n:longint;
econ,evol,tvol,wantcon:extended;
procedure sort(l,r:longint; var a:arr);
var
i,j,x:longint;
y:datetype;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2].con;
repeat
while a[i].con<x do inc(i);
while x<a[j].con do dec(j);
if not(i>j) then begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-1;
end;
until i>j;
if l<j then sort(l,j,a);
if i<r then sort(i,r,a);
end;
begin
readln(n);
for i:=1 to n do read(date[i].con);
econ:=0;
evol:=0;
for i:=1 to n do begin
read(date[i].vol);
econ:=(econ*evol+date[i].con*date[i].vol)/(evol+date[i].vol);
evol:=evol+date[i].vol;
end;
sort(1,n,date);
readln(wantcon);
if econ=wantcon then begin
writeln(evol:0:5);
halt;
end;
if econ<wantcon then begin
econ:=0;
evol:=0;
i:=n;
while econ>wantcon do begin
econ:=(econ*evol+date[i].con*date[i].vol)/(evol+date[i].vol);
evol:=evol+date[i].vol;
dec(i);
if i=-1 then begin
writeln(’0’);
halt;
end;
end;
if econ=wantcon then begin
writeln(evol:0:5);
halt;
end;
inc(i);
econ:=(econ*evol-date[i].con*date[i].vol)/(evol-date[i].vol);
evol:=evol-date[i].vol;
tvol:=abs((evol*(wantcon-econ))/(date[i-1].con-wantcon));
evol:=evol+tvol;
writeln(evol:0:5);
halt;
end
else begin
econ:=0;
evol:=0;
i:=1;
while econ<wantcon do begin
econ:=(econ*evol+date[i].con*date[i].vol)/(evol+date[i].vol);
evol:=evol+date[i].vol;
inc(i);
if i=n+2 then begin
writeln(’0’);
halt;
end;
end;
if econ=wantcon then begin
writeln(evol:0:5);
halt;
end;
dec(i);
econ:=(econ*evol-date[i].con*date[i].vol)/(evol-date[i].vol);
evol:=evol-date[i].vol;
tvol:=abs((evol*(wantcon-econ))/(date[i+1].con-wantcon));
evol:=evol+tvol;
writeln(evol:0:5);
halt;
end;
end.
evol:=evol+tvol; writeln(evol:0:5);
writeln(evol:0:5);
halt;
end;
end.