#include<bits/stdc++.h>

using namespace std;

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (root+root)
#define sag (root+root+1)
#define orta ((bas+son)/2)
#define ll long long
#define pii pair<int,int>
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)

const int N=2e5+5;
const int mod=1e9+7;
const int inf=1e9+7;

int n,i,j,k,w;
int P[N],ord[N],T[N];

bool bek;

ll q,e,all;

double bas,son,ort,last;
double ans[N];

vector<pair<double,int> > Q;

bool cmp(int x,int y){
//	if((ll)P[x]*T[y]==(ll)P[y]*T[x])
//		return P[x]<P[y];
	return (ll)P[x]*T[y]>(ll)P[y]*T[x];
}

main(){

	scanf("%d",&n);

	for(i=1 ; i<=n ; i++)
		scanf("%d",P+i);
	for(i=1 ; i<=n ; i++){
		scanf("%d",T+i);
		all+=T[i];
		ord[i]=i;
	}

	bas=0;
	son=1;

	sort(ord+1,ord+n+1,cmp);

	for(j=1 ; j<=50 ; j++){
		ort=(bas+son)/2.0;
		q=0;
		Q.clear();
		for(i=1 ; i<=n ; i++){
			k=i;
			e=T[ord[k]];
			while(k<n and (ll)(P[ord[i]]*T[ord[k+1]])==(ll)(P[ord[k+1]]*T[ord[i]])){
				e+=T[ord[k+1]];
				k++;
			}
			w=i;
			while(w<=k){
				Q.pb(mp(P[ord[w]]*(1.0-ort*((double)(q+e)/all)),P[ord[w]]));
				Q.pb(mp(P[ord[w]]*(1.0-ort*((double)(q+T[ord[w]])/all)),P[ord[w]]));
				w++;
			}
			q+=e;
			i=k;
		}
		last=0;
		bek=1;
		sort(Q.begin(),Q.end());
		last=0;
		for(i=0 ; i<Q.size() ; i++){
			if(Q[i].nd<last)
				bek=0;
			last=Q[i].nd;
		}
		if(bek)
			bas=ort;
		else son=ort;
	}

	printf("%.8lf",bas);
}


#include<bits/stdc++.h>

using namespace std;

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (root+root)
#define sag (root+root+1)
#define orta ((bas+son)/2)
#define ll long long
#define pii pair<int,int>
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)

const int N=1e5+5;
const int mod=1e9+7;
const int inf=1e9+7;

int n,i,j,k,w;
int P[N],ord[N],T[N];

pii A[N];

bool bek;

ll q,e,all;

double bas,son,ort,last;
double ans[N];

vector<pair<double,int> > Q;

bool cmp(int x,int y){
	if((ll)P[x]*T[y]==(ll)P[y]*T[x])
		return P[x]<P[y];
	return P[x]*T[y]>P[y]*T[x];
}

main(){

	scanf("%d",&n);

	for(i=1 ; i<=n ; i++){
		scanf("%d",P+i);
		A[i].st=P[i];
		A[i].nd=i;
	}
	for(i=1 ; i<=n ; i++){
		scanf("%d",T+i);
		all+=T[i];
		ord[i]=i;
	}

	sort(A+1,A+n+1);

	bas=0;
	son=1;

	sort(ord+1,ord+n+1,cmp);

	for(j=1 ; j<=50 ; j++){
		ort=(bas+son)/2.0;
		q=0;
		Q.clear();
		for(i=1 ; i<=n ; i++){
			k=i;
			e=T[ord[k]];
			while(k<n and (ll)(P[ord[i]]*T[ord[k+1]])==(ll)(P[ord[k+1]]*T[ord[i]])){
				e+=T[ord[k+1]];
				k++;
			}
			w=i;
			while(w<=k){
				Q.pb(mp(P[ord[w]]*(1.0-ort*((double)(q+e)/all)),P[ord[w]]));
				Q.pb(mp(P[ord[w]]*(1.0-ort*((double)(q+T[ord[w]])/all)),P[ord[w]]));
				w++;
			}
			q+=e;
			i=k;
		}
		last=0;
		bek=1;
		sort(Q.begin(),Q.end());
		last=0;
		for(i=0 ; i<Q.size() ; i++){
			if(Q[i].nd<last)
				bek=0;
			last=Q[i].nd;
		}
		if(bek)
			bas=ort;
		else son=ort;
	}

	printf("%.8lf",bas);
}


#include<bits/stdc++.h>

using namespace std;

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (root+root)
#define sag (root+root+1)
#define orta ((bas+son)/2)
#define ll long long
#define pii pair<int,int>
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)

const int N=2e5+5;
const int mod=1e9+7;
const int inf=1e9+7;

int n,i,j,k,w;
int P[N],ord[N],T[N];

bool bek;

ll q,e,all;

double bas,son,ort,last;
double ans[N];

vector<pair<double,int> > Q;

bool cmp(int x,int y){
	if((ll)P[x]*T[y]==(ll)P[y]*T[x])
		return P[x]<P[y];
	return (ll)P[x]*T[y]>(ll)P[y]*T[x];
}

main(){

	scanf("%d",&n);

	for(i=1 ; i<=n ; i++)
		scanf("%d",P+i);
	for(i=1 ; i<=n ; i++){
		scanf("%d",T+i);
		all+=T[i];
		ord[i]=i;
	}

	bas=0;
	son=1;

	sort(ord+1,ord+n+1,cmp);

	for(j=1 ; j<=50 ; j++){
		ort=(bas+son)/2.0;
		q=0;
		Q.clear();
		for(i=1 ; i<=n ; i++){
			k=i;
			e=T[ord[k]];
			while(k<n and (ll)(P[ord[i]]*T[ord[k+1]])==(ll)(P[ord[k+1]]*T[ord[i]])){
				e+=T[ord[k+1]];
				k++;
			}
			w=i;
			while(w<=k){
				Q.pb(mp(P[ord[w]]*(1.0-ort*((double)(q+e)/all)),P[ord[w]]));
				Q.pb(mp(P[ord[w]]*(1.0-ort*((double)(q+T[ord[w]])/all)),P[ord[w]]));
				w++;
			}
			q+=e;
			i=k;
		}
		last=0;
		bek=1;
		sort(Q.begin(),Q.end());
		last=0;
		for(i=0 ; i<Q.size() ; i++){
			if(Q[i].nd<last)
				bek=0;
			last=Q[i].nd;
		}
		if(bek)
			bas=ort;
		else son=ort;
	}

	printf("%.8lf",bas);
}


#include<bits/stdc++.h>

using namespace std;

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (root+root)
#define sag (root+root+1)
#define orta ((bas+son)/2)
#define ll long long
#define pii pair<int,int>
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)
#define double long double

const int N=1e5+5;
const int mod=1e9+7;
const int inf=1e9+7;

int n,i,j,k,w;
int P[N],ord[N],T[N];

pii A[N];

bool bek;

ll q,e,all;

double bas,son,ort,last;
double ans[N];

vector<pair<double,int> > Q;

bool cmp(int x,int y){
	if((ll)P[x]*T[y]==(ll)P[y]*T[x])
		return P[x]>P[y];
	return P[x]*T[y]>P[y]*T[x];
}

main(){

	scanf("%d",&n);

	for(i=1 ; i<=n ; i++){
		scanf("%d",P+i);
		A[i].st=P[i];
		A[i].nd=i;
	}
	for(i=1 ; i<=n ; i++){
		scanf("%d",T+i);
		all+=T[i];
		ord[i]=i;
	}

	sort(A+1,A+n+1);

	bas=0;
	son=1;

	sort(ord+1,ord+n+1,cmp);

	for(j=1 ; j<=50 ; j++){
		ort=(bas+son)/2.0;
		q=0;
		Q.clear();
		for(i=1 ; i<=n ; i++){
			k=i;
			e=T[ord[k]];
			while(k<n and (ll)(P[ord[i]]*T[ord[k+1]])==(ll)(P[ord[k+1]]*T[ord[i]])){
				e+=T[ord[k+1]];
				k++;
			}
			w=i;
			while(w<=k){
				Q.pb(mp(P[ord[w]]*(1.0-ort*((double)(q+e)/all)),P[ord[w]]));
				Q.pb(mp(P[ord[w]]*(1.0-ort*((double)(q+T[ord[w]])/all)),P[ord[w]]));
				w++;
			}
			q+=e;
			i=k;
		}
		last=0;
		bek=1;
		sort(Q.begin(),Q.end());
		last=0;
		for(i=0 ; i<Q.size() ; i++){
			if(Q[i].nd<last)
				bek=0;
			last=Q[i].nd;
		}
		if(bek)
			bas=ort;
		else son=ort;
	}

	printf("%.8Lf",bas);
}


#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

struct node
{
	int x,y;
	bool operator <(node a)const
	{
		ll A=ll(y)*a.x,B=ll(x)*a.y;
		if (A<B) return 1;
		if (A>B) return 0;
		return x<a.x;
	}
}a[150010];

int n,b[150010],d[150010];
double c[150010];
ll T;

inline int lowbit(int x) {return x&(-x);}

void change(int x,double y)
{
	while (x<=n)
	{
		c[x]=max(c[x],y);x+=lowbit(x);
	}
}

double query(int x)
{
	double y=-1.0;
	while (x)
	{
		y=max(y,c[x]);x-=lowbit(x);
	}
	return y;
}

bool check(double x)
{
	double ma=-1.0;
	for (int i=1;i<=n;i++) c[i]=-1.0;
	ll t=0;int i=1;
	while (i<=n)
	{
		int k=i;ll tt=0;
		while (k<=n&&ll(a[i].x)*a[k].y==ll(a[i].y)*a[k].x)
		{
			double w=(1-x*(t+a[k].y)/T)*a[k].x;
			change(d[k],w);tt+=a[k].y;k++;
		}
		t+=tt;
		for (int j=i;j<k;j++)
		{
			double w=(1-x*t/T)*a[j].x;
			if (query(d[j]-1)>w) return 0;
		}
		i=k;
	}
	return 1;
}

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	read(n);
	for (int i=1;i<=n;i++) read(a[i].x);
	for (int i=1;i<=n;i++) read(a[i].y);
	sort(a+1,a+n+1);
	T=0;for (int i=1;i<=n;i++) T+=a[i].y;
	for (int i=1;i<=n;i++) b[i]=a[i].x;
	sort(b+1,b+n+1);
	int m=1;for (int i=2;i<=n;i++) if (b[i]!=b[m]) b[++m]=b[i];
	for (int i=1;i<=n;i++) d[i]=lower_bound(b+1,b+m+1,a[i].x)-b;
	double l=0,r=1;
	for (int i=0;i<50;i++)
	{
		double mid=(l+r)/2;
		if (check(mid)) l=mid; else r=mid;
	}
	printf("%.10lf\n",(l+r)/2);
	return 0;
}


#include<stdio.h>
#include<algorithm>
#define N 150005
using namespace std;
typedef long long LL;LL T;
double EPS=1e-7,L[N],R[N],l,r,mid;
struct data{
	int p,t;LL x,y,sum;
	int operator < (const data &b)const{return 1ll*p*b.t>1ll*b.p*t;}
}a[N];int U[N],n,i,j,k;
int cmp(const data &a,const data &b){return a.p<b.p;}
int Find(double c){
	c/=T;int k=0;
	for (int i=1;i<*U;i++){
		L[i]=L[i-1];
		for (;k<n&&a[k+1].p<=U[i];)
			++k,L[i]=max(L[i],(1.-c*(a[k].x+a[k].t))*a[k].p);
  }k=n+1;
	for (int i=*U;i>1;i--){
		R[i]=(i==U[0])?1e60:R[i+1];
		for (;k>1&&a[k-1].p>=U[i];)
			--k,R[i]=min(R[i],(1.-c*a[k].y)*a[k].p);
		if (L[i-1]>R[i]) return 1;
	}return 0;
}
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d",&a[i].p);
	for (i=1;i<=n;i++)
		scanf("%d",&a[i].t),T+=a[i].t;
	sort(a+1,a+n+1);
	for (i=1;i<=n;i++)
		a[i].sum=a[i-1].sum+a[i].t;
	for (k=1,i=2;i<=n+1;i++)
		if (i==n+1||a[i-1]<a[i]){
			for (j=k;j<i;j++)
				a[j].x=a[k-1].sum,a[j].y=a[i-1].sum;
			k=i;
	  }
	sort(a+1,a+n+1,cmp);
	for (i=1;i<=n;i++) U[i]=a[i].p;
	*U=unique(U+1,U+n+1)-(U+1);
	l=0;r=1;
	while (l+EPS<r){
		mid=(l+r)/2.;
		if (Find(mid)) r=mid;else l=mid;
  }printf("%.7f\n",l);
}


#include<cstdio>
#include<algorithm>
#define rep(i,x,y) for(int i=(x);i<=(y);i++)
#define dep(i,x,y) for(int i=(x);i>=(y);i--)
#define N 200000
using namespace std;
int n,x,u,tt[N];long long T,T0,T1,t0[N],t1[N];double l,r,m,P,pt[N];
struct pr{long long p,t;int id;}a[N];
inline bool cmp0(const pr &x,const pr &y){return x.p<y.p;}
inline bool cmp(const pr &x,const pr &y){return x.p*y.t>y.p*x.t;}
int main(){
	scanf("%d",&n);
	rep(i,1,n)scanf("%I64d",&a[i].p);
	rep(i,1,n)scanf("%I64d",&a[i].t);
	rep(i,1,n)T+=a[i].t;
	sort(a+1,a+n+1,cmp0);rep(i,1,n)a[i].id=i;
	sort(a+1,a+n+1,cmp);rep(i,1,n)tt[a[i].id]=i;
	l=0;r=1;m=0.5;T0=T1=0;
	rep(i,1,n){
		if(a[i].p*a[i-1].t!=a[i-1].p*a[i].t)T0=T1;
		T1+=a[i].t;t0[i]=T0+a[i].t;
	}T0=T1=T;
	dep(i,n,1){
		if(a[i].p*a[i+1].t!=a[i+1].p*a[i].t)T0=T1;
		T1-=a[i].t;t1[i]=T0;
	}
	for(;r-l>1e-7;m=(l+r)/2){
		rep(i,1,n){
			P=a[tt[i]].p*(1-m*t0[tt[i]]/T);
			pt[i]=pt[i-1];if(P>pt[i])pt[i]=P;
		}x=n;u=1;
		dep(i,n,1){
			while(a[tt[x]].p>=a[tt[i]].p)x--;
			P=a[tt[i]].p*(1-m*t1[tt[i]]/T);
			if(P<pt[x]){u=0;break;}
		}
		if(u)l=m;else r=m;
	}
	printf("%.7lf\n",m);
}


#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int MAXN = 150005;

int N;
int p[MAXN], t[MAXN];
ll mini[MAXN], maks[MAXN];
int idx[MAXN];
ll pref[MAXN];
pii task[MAXN];
ld best[MAXN];
int where[MAXN];
ll T;

void load() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
        scanf("%d", p + i);
    for (int i = 0; i < N; i++)
        scanf("%d", t + i);
}

ld eval(int init, ll x, ld c) {
    return init * (1 - c * x / T);
}

bool check(ld c) {
    for (int i = 0; i < N; i++) {
        best[i] = eval(task[i].first, mini[task[i].second], c);
        if (i) best[i] = max(best[i], best[i - 1]);
    }

    for (int i = 0; i < N; i++) {
        ld tmp = eval(task[i].first, maks[task[i].second], c);
        ld cand = where[i] == -1 ? 0 : best[where[i]];
        if (tmp < cand) return false;
    }

    return true;
}

bool cmp(const int &l, const int &r) {
    return (ll)p[l] * t[r] > (ll)p[r] * t[l];
}

ld solve() {
    p[N] = 1;
    t[N] = (int)1e9;
    for (int i = 0; i < N; i++)
        idx[i] = i;
    sort(idx, idx + N, cmp);
    idx[N] = N;

    pref[0] = t[idx[0]];
    for (int i = 1; i < N; i++)
        pref[i] = pref[i - 1] + t[idx[i]];

    for (int i = 0; i < N; i++) {
        int pos = lower_bound(idx, idx + N, i, cmp) - idx;
        mini[i] = (pos ? pref[pos - 1] : 0) + t[i];
        pos = upper_bound(idx, idx + N, i, cmp) - idx;
        maks[i] = pref[pos - 1];
    }

    for (int i = 0; i < N; i++) {
        task[i] = pii(p[i], i);
        T += t[i];
    }
    sort(task, task + N);

    for (int i = 0; i < N; i++)
        where[i] = lower_bound(task, task + N, pii(task[i].first, -1)) - task - 1;

    ld lo = 0, hi = 1;
    for (int i = 0; i < 500; i++) {
        ld mid = (lo + hi) / 2;
        if (check(mid)) lo = mid;
        else hi = mid;
    }

    return lo;
}

int main() {
    load();
    printf("%.11lf\n", (double)solve());
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcount(n)
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> void setmin(T& a, T val) {if (a > val) a = val;}
template<class T> void setmax(T& a, T val) {if (a < val) a = val;}
void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

int compare(pi a, pi b) {
	return (ll) a.fi * b.se > (ll) a.se * b.fi;
}

void solve() {
	int n; cin>>n;
	vii v(n);
	ll ttime = 0;
	FOR(i, 0, n) cin>>v[i].fi;
	FOR(i, 0, n) cin>>v[i].se, ttime += v[i].se;
	sort(all(v), compare);
	ld l = 0, r = 1;
	FOR(_, 0, 30) {
		ld m = (l + r) / 2;
		ll t = 0;
		int cur = 0;
		vector<pair<int, pair<ld, ld> > > vx;
		FOR(i, 1, n + 1) {
			if (i == n || (ll) v[i].fi * v[i - 1].se != (ll) v[i].se * v[i - 1].fi) {
				ll tot = 0;
				FOR(j, cur, i) {
					tot += v[j].se;
				}
				FOR(j, cur, i) {
					ld dmin = v[j].fi * (1 - m * (t + tot) / ttime);
					ld dmax = v[j].fi * (1 - m * (t + v[j].se) / ttime);
					vx.pb(mp(v[j].fi, mp(dmin, dmax)));
				}
				cur = i;
				t += tot;
			}
		}
		sort(all(vx));
		int ok = 1;
		ld dmax = 0;
		FOR(i, 0, n) {
			if (vx[i].se.fi < dmax) {
				ok = 0;
				break;
			}
			ld tmp = vx[i].se.se;
			int cur = i++;
			while (i < n && vx[i].fi == vx[cur].fi) {
				if (vx[cur].se.fi < dmax) {
					ok = 0;
					break;
				}
				setmax(tmp, vx[i].se.se);
				i++;
			}
			setmax(dmax, tmp);
			i--;
		}
		if (ok) l = m; else r = m;
	}
	cout<<prec(9)<<l<<"\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcount(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> void setmin(T& a, T val) {if (a > val) a = val;}
template<class T> void setmax(T& a, T val) {if (a < val) a = val;}
void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

int compare(pi a, pi b) {
	return (ll) a.fi * b.se >= (ll) a.se * b.fi;
}

void solve() {
	int n; cin>>n;
	vii v(n);
	ll ttime = 0;
	FOR(i, 0, n) cin>>v[i].fi;
	FOR(i, 0, n) cin>>v[i].se, ttime += v[i].se;
	sort(all(v), compare);
	ld l = 0, r = 1;
	FOR(_, 0, 100) {
		ld m = (l + r) / 2;
		ll t = 0;
		int cur = 0;
		vector<pair<int, pair<ld, ld> > > vx;
		FOR(i, 1, n + 1) {
			if (i == n || (ll) v[i].fi * v[i - 1].se != (ll) v[i].se * v[i - 1].fi) {
				ll tot = 0;
				FOR(j, cur, i) {
					tot += v[j].se;
				}
				FOR(j, cur, i) {
					ld dmin = v[j].fi * (1 - m * (t + tot) / ttime);
					ld dmax = v[j].fi * (1 - m * (t + v[j].se) / ttime);
					vx.pb(mp(v[j].fi, mp(dmin, dmax)));
				}
				cur = i;
				t += tot;
			}
		}
		sort(all(vx));
		int ok = 1;
		ld dmax = 0;
		FOR(i, 0, n) {
			if (vx[i].se.fi < dmax) {
				ok = 0;
				break;
			}
			ld tmp = vx[i].se.se;
			int cur = i++;
			while (i < n && vx[i].fi == vx[cur].fi) {
				if (vx[cur].se.fi < dmax) {
					ok = 0;
					break;
				}
				setmax(tmp, vx[i].se.se);
				i++;
			}
			setmax(dmax, tmp);
			i--;
		}
		if (ok) l = m; else r = m;
	}
	cout<<prec(9)<<l<<"\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcount(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> void setmin(T& a, T val) {if (a > val) a = val;}
template<class T> void setmax(T& a, T val) {if (a < val) a = val;}
void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

int compare(pi a, pi b) {
	return (ll) a.fi * b.se > (ll) a.se * b.fi;
}

void solve() {
	int n; cin>>n;
	vii v(n);
	ll ttime = 0;
	FOR(i, 0, n) cin>>v[i].fi;
	FOR(i, 0, n) cin>>v[i].se, ttime += v[i].se;
	sort(all(v), compare);
	ld l = 0, r = 1;
	FOR(_, 0, 100) {
		ld m = (l + r) / 2;
		ll t = 0;
		int cur = 0;
		vector<pair<int, pair<ld, ld> > > vx;
		FOR(i, 1, n + 1) {
			if (i == n || (ll) v[i].fi * v[i - 1].se != (ll) v[i].se * v[i - 1].fi) {
				ll tot = 0;
				FOR(j, cur, i) {
					tot += v[j].se;
				}
				FOR(j, cur, i) {
					ld dmin = v[j].fi * (1 - m * (t + tot) / ttime);
					ld dmax = v[j].fi * (1 - m * (t + v[j].se) / ttime);
					vx.pb(mp(v[j].fi, mp(dmin, dmax)));
				}
				cur = i;
				t += tot;
			}
		}
		sort(all(vx));
		int ok = 1;
		ld dmax = 0;
		FOR(i, 0, n) {
			if (vx[i].se.fi < dmax) {
				ok = 0;
				break;
			}
			ld tmp = vx[i].se.se;
			int cur = i++;
			while (i < n && vx[i].fi == vx[cur].fi) {
				if (vx[cur].se.fi < dmax) {
					ok = 0;
					break;
				}
				setmax(tmp, vx[i].se.se);
				i++;
			}
			setmax(dmax, tmp);
			i--;
		}
		if (ok) l = m; else r = m;
	}
	cout<<prec(9)<<l<<"\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcount(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> void setmin(T& a, T val) {if (a > val) a = val;}
template<class T> void setmax(T& a, T val) {if (a < val) a = val;}
void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

const int maxn = 150010;
int n;

int compare(pi a, pi b) {
	return (ll) a.fi * b.se >= (ll) a.se * b.fi;
}

void solve() {
	cin>>n;
	vii v(n);
	ll ttime = 0;
	FOR(i, 0, n) cin>>v[i].fi;
	FOR(i, 0, n) cin>>v[i].se, ttime += v[i].se;
	sort(all(v), compare);
	ld l = 0, r = 1;
	FOR(_, 0, 100) {
		ld m = (l + r) / 2;
		ll t = 0;
		int cur = 0;
		vector<pair<int, pair<ld, ld> > > vx;
		FOR(i, 1, n + 1) {
			if (i == n || (ll) v[i].fi * v[i - 1].se != (ll) v[i].se * v[i - 1].fi) {
				ll tot = 0;
				FOR(j, cur, i) {
					tot += v[j].se;
				}
				FOR(j, cur, i) {
					ld dmin = v[j].fi * (1 - m * (t + tot) / ttime);
					ld dmax = v[j].fi * (1 - m * (t + v[j].se) / ttime);
					vx.pb(mp(v[j].fi, mp(dmin, dmax)));
				}
				cur = i;
				t += tot;
			}
		}
		sort(all(vx));
		int ok = 1;
		ld dmax = 0;
		FOR(i, 0, n) {
			if (vx[i].se.fi < dmax) {
				ok = 0;
				break;
			}
			setmax(dmax, vx[i].se.se);
		}
		if (ok) l = m; else r = m;
	}
	cout<<prec(9)<<l<<"\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
pair<LL,LL> pts[500000];
LL r = 0;
int main(){
	LL n;
	cin >> n;
	LL p[n];
	LL t[n];
	for(LL i = 0; i < n; i++){
		cin >> p[i];
	}
	LL T = 0;
	for(LL i = 0; i < n; i++){
		cin >> t[i];
		T += t[i];
	}
	pair<double,pair<LL,LL> > x[n];
	LL newp[n];
	LL newt[n];
	for(LL i = 0; i < n; i++){
		x[i].first = -((double)p[i])/((double)t[i]);
		x[i].second.first = -p[i];
		x[i].second.second = -t[i];
	}
	sort(x,x+n);
	for(LL i = 0; i < n; i++){
		newp[i] = x[i].second.first * -1;
		newt[i] = x[i].second.second * -1;
		//	cout << newp[i] << " " << newt[i] << endl;
	}
	LL s = 0;
	LL totaltime = 0;
	while(s < n){
		LL e=s;
		LL mintime = totaltime;
		LL maxtime = mintime + newt[e];
		while(e < n-1 && newp[e]*newt[e+1] == newp[e+1]*newt[e]){
			e++;
			maxtime += newt[e];
		}
		for(LL i = s; i <= e; i++){
			pts[r++] = make_pair(newp[i],-(mintime+newt[i]));
			pts[r++] = make_pair(newp[i],-maxtime);
		}
		s = e+1;
		totaltime = maxtime;
	}
	sort(pts,pts+r);
	double c = 1;
	for(LL i = 0; i < r; i++){
		pts[i].second *= -1;
		//cout << pts[i].first << " " << pts[i].second << endl;
	}
	for(LL i = 0; i < r-1; i++){
		if(pts[i].first < pts[i+1].first){
			double z = (double)T;
			z *= (double)(pts[i+1].first - pts[i].first);
			double den = (double)(pts[i+1].first*pts[i+1].second - pts[i].first*pts[i].second);
			if(den < 0) continue;
			c = min(c,z/den);
		}
	}
	printf("%.11lf\n",c);
}


#include <algorithm>
#include <iostream>
#include <iomanip>
using namespace std;
const int MAX = 150005;
pair<int, int> p[MAX];
double lo[MAX], hi[MAX], mn[MAX], mx[MAX];
long long sumt;
int ps[MAX], n;
bool cmp(pair<int, int> a, pair<int, int> b)
{
	return (a.first * b.second > b.first * a.second);
}
bool check(double c)
{
	long long t = 0;
	for (int i = 0; i < n; i++)
	{
		int j = i + 1;
		long long cur = p[i].second;
		while (j < n && !cmp(p[j - 1], p[j]) && !cmp(p[j], p[j - 1]))
			cur += p[j++].second;
		for (int x = i; x < j; x++)
		{
			hi[x] = p[x].first * (1.0 - c * (t + p[x].second) / sumt);
			lo[x] = p[x].first * (1.0 - c * (t + cur) / sumt);
		}
		i = j - 1;
		t += cur;
	}
	for (int i = 0; i < n; i++)
	{
		mx[i] = hi[ps[i]];
		if (i)
			mx[i] = max(mx[i], mx[i - 1]);
	}
	for (int i = n - 1; i >= 0; i--)
	{
		mn[i] = lo[ps[i]];
		if (i < n - 1)
			mn[i] = min(mn[i], mn[i + 1]);
	}
	for (int i = 1; i < n; i++)
		if (p[ps[i - 1]].first != p[ps[i]].first && mx[i - 1] > mn[i])
			return false;
	return true;
}
bool cmp2(int x, int y)
{
	return (p[x].first < p[y].first);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i].first;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i].second;
		sumt += p[i].second;
	}
	sort(p, p + n, cmp);
	for (int i = 0; i < n; i++)
		ps[i] = i;
	sort(ps, ps + n, cmp2);
	double l = 0.0, r = 1.0;
	for (int i = 0; i < 50; i++)
	{
		double mid = (l + r) * 0.5;
		if (check(mid))
			l = mid;
		else
			r = mid;
	}
	cout << setprecision(9) << fixed << l << endl;
	return 0;
}


#include <algorithm>
#include <iostream>
#include <iomanip>
using namespace std;
const int MAX = 150005;
pair<int, int> p[MAX];
double lo[MAX], hi[MAX], mn[MAX], mx[MAX];
long long sumt;
int ps[MAX], n;
bool cmp(pair<int, int> a, pair<int, int> b)
{
	return (1LL * a.first * b.second > 1LL * b.first * a.second);
}
bool check(double c)
{
	long long t = 0;
	for (int i = 0; i < n; i++)
	{
		int j = i + 1;
		long long cur = p[i].second;
		while (j < n && !cmp(p[j - 1], p[j]) && !cmp(p[j], p[j - 1]))
			cur += p[j++].second;
		for (int x = i; x < j; x++)
		{
			hi[x] = p[x].first * (1.0 - c * (t + p[x].second) / sumt);
			lo[x] = p[x].first * (1.0 - c * (t + cur) / sumt);
		}
		i = j - 1;
		t += cur;
	}
	for (int i = 0; i < n; i++)
	{
		mx[i] = hi[ps[i]];
		if (i)
			mx[i] = max(mx[i], mx[i - 1]);
	}
	for (int i = n - 1; i >= 0; i--)
	{
		mn[i] = lo[ps[i]];
		if (i < n - 1)
			mn[i] = min(mn[i], mn[i + 1]);
	}
	for (int i = 1; i < n; i++)
		if (p[ps[i - 1]].first != p[ps[i]].first && mx[i - 1] > mn[i])
			return false;
	return true;
}
bool cmp2(int x, int y)
{
	return (p[x].first < p[y].first);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i].first;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i].second;
		sumt += p[i].second;
	}
	sort(p, p + n, cmp);
	for (int i = 0; i < n; i++)
		ps[i] = i;
	sort(ps, ps + n, cmp2);
	double l = 0.0, r = 1.0;
	for (int i = 0; i < 50; i++)
	{
		double mid = (l + r) * 0.5;
		if (check(mid))
			l = mid;
		else
			r = mid;
	}
	cout << setprecision(9) << fixed << l << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long int ll;

struct elem {
  ll p,t;
  elem() {}
  elem(int p,int t) : p(p),t(t) {}
};

bool operator<(elem e1,elem e2)
{
  return e2.t*e1.p>e1.t*e2.p;
}

bool operator==(elem e1,elem e2)
{
  return e2.t*e1.p==e1.t*e2.p;
}

int n;
vector<elem> v;
const double error=1e-7;
const int limite=1000000;
ll sumat[limite];
double xmax[limite];
double xmin[limite];
int indice[limite];

bool compara(int i1,int i2)
{
  return v[i1].p<v[i2].p;
}

double computacmax(int i,double c)
{
  return v[i].p*(1-c*xmin[i]/sumat[n-1]);
}

double computacmin(int i,double c)
{
  return v[i].p*(1-c*xmax[i]/sumat[n-1]);
}

bool puede(double c)
{
  double minimo=computacmin(indice[n-1],c);
  for (int i=n-2;i>=0;i--) {
    if (computacmax(indice[i],c)>minimo) return false;
    minimo=min(minimo,computacmin(indice[i],c));
  }
  return true;
}

int main()
{
  ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(10);
  cin>>n;
  v=vector<elem> (n);
  for (int i=0;i<n;i++)
    cin>>v[i].p;
  for (int i=0;i<n;i++)
    cin>>v[i].t;
  sort(v.begin(),v.end());
  for (int i=0;i<n;i++)
    sumat[i]=(i>0?sumat[i-1]:0)+v[i].t;
  {
    for (int i=0;i<n;i++) {
      if (i==0 or v[i-1]<v[i]) {
	int ifin=i;
	while (ifin+1<n and v[i]==v[ifin+1]) ifin++;
	double xma=sumat[ifin];
	double xmi=i>0?sumat[i-1]:0;
	for (int j=i;j<=ifin;j++) {
	  xmax[j]=xma;
	  xmin[j]=xmi+v[j].t;
	}
      }
    }
  }
  for (int i=0;i<n;i++)
    indice[i]=i;
  sort(indice,indice+n,compara);
  double inf=0;
  double sup=1;
  while (inf+error<sup) {
    double med=(inf+sup)/2.0;
    if (puede(med)) inf=med;
    else sup=med;
  }
  cout<<inf<<endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long int ll;

struct elem {
  ll p,t;
  elem() {}
  elem(int p,int t) : p(p),t(t) {}
};

bool operator<(elem e1,elem e2)
{
  return e2.t*e1.p>e1.t*e2.p;
}

bool operator==(elem e1,elem e2)
{
  return e2.t*e1.p==e1.t*e2.p;
}

int n;
vector<elem> v;
const double error=1e-7;
const double errorc=1e-10;
const int limite=1000000;
ll sumat[limite];
double xmax[limite];
double xmin[limite];
int indice[limite];

bool compara(int i1,int i2)
{
  return v[i1].p<v[i2].p;
}

double computacmax(int i,double c)
{
  return v[i].p*(1-c*xmin[i]/sumat[n-1]);
}

double computacmin(int i,double c)
{
  return v[i].p*(1-c*xmax[i]/sumat[n-1]);
}

bool puede(double c)
{
  double minimo=computacmin(indice[n-1],c);
  int i=n-1;
  while (i>0 and v[indice[i-1]].p==v[indice[i]].p) {
    i--;
    minimo=min(minimo,computacmin(indice[i],c));
  }
  for (i--;i>=0;i--) {
    if (v[indice[i]].p<v[indice[i+1]].p) {
      int iini=i;
      while (iini>0 and v[indice[iini-1]].p==v[indice[i]].p) iini--;
      for (int j=iini;j<=i;j++)
	if (computacmax(indice[j],c)>minimo+errorc) return false;
      for (int j=iini;j<=i;j++)
	minimo=min(minimo,computacmin(indice[j],c));
    }
  }
  return true;
}

int main()
{
  ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(10);
  cin>>n;
  v=vector<elem> (n);
  for (int i=0;i<n;i++)
    cin>>v[i].p;
  for (int i=0;i<n;i++)
    cin>>v[i].t;
  sort(v.begin(),v.end());
  for (int i=0;i<n;i++)
    sumat[i]=(i>0?sumat[i-1]:0)+v[i].t;
  {
    for (int i=0;i<n;i++) {
      if (i==0 or v[i-1]<v[i]) {
	int ifin=i;
	while (ifin+1<n and v[i]==v[ifin+1]) ifin++;
	double xma=sumat[ifin];
	double xmi=i>0?sumat[i-1]:0;
	for (int j=i;j<=ifin;j++) {
	  xmax[j]=xma;
	  xmin[j]=xmi+v[j].t;
	}
      }
    }
  }
  for (int i=0;i<n;i++)
    indice[i]=i;
  sort(indice,indice+n,compara);
  double inf=0;
  double sup=1;
  while (inf+error<sup) {
    double med=(inf+sup)/2.0;
    if (puede(med)) inf=med;
    else sup=med;
  }
  cout<<inf<<endl;
}


/*/ Author: kal013 /*/
#include "bits/stdc++.h"
#include <cstdio>
using namespace std;
#define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef vector<ppi> vppi;
typedef map<int,int> mii;
typedef map<int,vi> mvi;
typedef map<pii,int> mpi;
typedef priority_queue<ppi,vppi,greater<ppi>> min_heap_ppi;
typedef priority_queue<ppi> max_heap_ppi;
#define For(i,n) for(int i=0;i<(int)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl "\n"
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) (v).begin(),(v).end()
#define sz(v) (v).size()
#define ll long long
//#define file cin
//#define codechef
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}

#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
#else
    #define trace(...)
#endif
const int maxn=1e6+100;
const int MaxN=1e5+100;
const int mod=1e9+7;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
#ifdef int
const int INF=1e16;
#else
const int INF=1e9;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set
#endif
#ifdef codechef
inline void read(int &x) {
    register int c = getchar_unlocked();
    x = 0;
    int neg = 0;

    for(; ((c<48 || c>57) && c != '-'); c = getchar_unlocked());

    if(c=='-') {
        neg = 1;
        c = getchar_unlocked();
    }

    for(; c>47 && c<58 ; c = getchar_unlocked()) {
        x = (x<<1) + (x<<3) + c - 48;
    }

    if(neg)
        x = -x;
}
inline void read_str(char *str){
    register char c = 0;
    register int i = 0;

    while (c < 33)
        c = getchar_unlocked();

    while (c != '\n') {
        str[i] = c;
        c = getchar_unlocked();
        i = i + 1;
    }

    str[i] = '\0';
}
#else
inline void read(int &x) {cin>>x;}
#endif
inline int fast_expo(int base,int power,int modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    // int tmp=ans;
    return ans;
}
inline int inv(int base,int modulo=mod){
    return fast_expo(base,modulo-2,modulo);
}

inline int fib(int n,int a=1,int b=1,int c=1,int d=0,int acca=0,int accb=1,int m=mod){
    if (n==0) return acca;

    if (n&1) return fib(n/2,((a*a)%m+(b*c)%m)%m,((a*b)%m+(b*d)%m)%m,(c*(a+d)%m)%m,((c*b)%m+(d*d)%m)%m,((a*acca)%m+(b*accb)%m)%m,((c*acca)%m+(d*accb)%m)%m,m);
    else return fib(n/2,((a*a)%m+(b*c)%m)%m,((a*b)%m+(b*d)%m)%m,(c*(a+d)%m)%m,((c*b)%m+(d*d)%m)%m,acca,accb,m);
}

/*/-----------------------------Code begins----------------------------------/*/
#define ld long double
int p[maxn],t[maxn];
int id[maxn];
ld mxsc[maxn],mnsc[maxn];

bool cmp(int i,int j){
	return (t[i]*p[j]<t[j]*p[i]);
}
bool eq(int i,int j){
	return (p[i]*t[j]==p[j]*t[i]);
}
bool cmp2(int i,int j){
	return (p[i]<p[j]);
}
ld EPS=1e-11;
bool gt(ld a,ld b){
    return (a>b && fabs(a-b)>EPS);
}
void solve(){
	int n,T=0;
	cin>>n;
	For(i,n) cin>>p[i];
	For(i,n) {cin>>t[i];T+=t[i];}
	For(i,n) id[i]=i;

	ld low=0,high=1;
	ld ans=0;
// 	trace(T);
	while(fabs(high-low)>EPS){
	    sort(id,id+n,cmp);
	    ld c=(high+low)/2.0;
	    bool sol=true;
	    int prv_tim=0;

	    int l=0;
	    while(l<n){
    		int r=l;
    		vi tmp;
    		tmp.pb(id[l]);
    		int tmp_time=t[id[l]];
    		while(r+1<n && eq(id[l],id[r+1])){
    			++r;
    			tmp.pb(id[r]);
    			tmp_time+=t[id[r]];
    		}
    		For(i,tmp.size()){
    			int x=tmp[i];

    			int t1=prv_tim+t[x],t2=prv_tim+tmp_time;
    			mxsc[x]=p[x]*(1.0-((ld)c*(t1))/((ld)T));
    			mnsc[x]=p[x]*(1.0-((ld)c*(t2))/((ld)T));
    // 			trace(x,p[x],mnsc[x],c,t1,t2,mxsc[x]);
    // 			int p1=p[x],p2=p[y];
    // 			ld currrr=(p2-p1)*T;
    // 			currrr/=((ld) p2*t2-p1*t1);
    // 			c=min(c,currrr);
    		}
    		prv_tim+=tmp_time;
    		l=r+1;
    	}
    	sort(id,id+n,cmp2);
    	ld mx=0;
    	For(i,n){
    	    if (gt(mx,mnsc[id[i]])){
    	        sol=false;
    	        break;
    	    }
    	    mx=max(mx,mxsc[id[i]]);
    	}
    	if (sol){
    	    ans=c;
    	    low=c;
    	}
    	else{
    	    high=c;
    	}
	}

	d1(ans);

}
signed main(){
    // Use "set_name".max_load_factor(0.25);"set_name".reserve(512); with unordered set
    // Uncomment codechef for large input files. Doesn't work on codeforces.
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
    fio;
    cout<<fixed<<setprecision(25);
    int t=1;
    // read(t);
    while(t--) {
        solve();
    }
}


/*/ Author: kal013 /*/
#include "bits/stdc++.h"
#include <cstdio>
using namespace std;
#define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef vector<ppi> vppi;
typedef map<int,int> mii;
typedef map<int,vi> mvi;
typedef map<pii,int> mpi;
typedef priority_queue<ppi,vppi,greater<ppi>> min_heap_ppi;
typedef priority_queue<ppi> max_heap_ppi;
#define For(i,n) for(int i=0;i<(int)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl "\n"
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) (v).begin(),(v).end()
#define sz(v) (v).size()
#define ll long long
//#define file cin
//#define codechef
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}

#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
#else
    #define trace(...)
#endif
const int maxn=1e6+100;
const int MaxN=1e5+100;
const int mod=1e9+7;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
#ifdef int
const int INF=1e16;
#else
const int INF=1e9;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set
#endif
#ifdef codechef
inline void read(int &x) {
    register int c = getchar_unlocked();
    x = 0;
    int neg = 0;

    for(; ((c<48 || c>57) && c != '-'); c = getchar_unlocked());

    if(c=='-') {
        neg = 1;
        c = getchar_unlocked();
    }

    for(; c>47 && c<58 ; c = getchar_unlocked()) {
        x = (x<<1) + (x<<3) + c - 48;
    }

    if(neg)
        x = -x;
}
inline void read_str(char *str){
    register char c = 0;
    register int i = 0;

    while (c < 33)
        c = getchar_unlocked();

    while (c != '\n') {
        str[i] = c;
        c = getchar_unlocked();
        i = i + 1;
    }

    str[i] = '\0';
}
#else
inline void read(int &x) {cin>>x;}
#endif
inline int fast_expo(int base,int power,int modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    // int tmp=ans;
    return ans;
}
inline int inv(int base,int modulo=mod){
    return fast_expo(base,modulo-2,modulo);
}

inline int fib(int n,int a=1,int b=1,int c=1,int d=0,int acca=0,int accb=1,int m=mod){
    if (n==0) return acca;

    if (n&1) return fib(n/2,((a*a)%m+(b*c)%m)%m,((a*b)%m+(b*d)%m)%m,(c*(a+d)%m)%m,((c*b)%m+(d*d)%m)%m,((a*acca)%m+(b*accb)%m)%m,((c*acca)%m+(d*accb)%m)%m,m);
    else return fib(n/2,((a*a)%m+(b*c)%m)%m,((a*b)%m+(b*d)%m)%m,(c*(a+d)%m)%m,((c*b)%m+(d*d)%m)%m,acca,accb,m);
}

/*/-----------------------------Code begins----------------------------------/*/
#define ld long double
int p[maxn],t[maxn];
int id[maxn];
ld mxsc[maxn],mnsc[maxn];

bool cmp(int i,int j){
	return (t[i]*p[j]<t[j]*p[i]);
}
bool eq(int i,int j){
	return (p[i]*t[j]==p[j]*t[i]);
}
bool cmp2(int i,int j){
	return (p[i]<p[j]);
}
ld EPS=1e-11;
bool gt(ld a,ld b){
    return (a>b && fabs(a-b)>EPS);
}
void solve(){
	int n,T=0;
	cin>>n;
	For(i,n) cin>>p[i];
	For(i,n) {cin>>t[i];T+=t[i];}
	For(i,n) id[i]=i;

	ld low=0,high=1;
	ld ans=0;
// 	trace(T);
	while(fabs(high-low)>EPS){
	    sort(id,id+n,cmp);
	    ld c=(high+low)/2.0;
	    bool sol=true;
	    int prv_tim=0;

	    int l=0;
	    while(l<n){
    		int r=l;
    		vi tmp;
    		tmp.pb(id[l]);
    		int tmp_time=t[id[l]];
    		while(r+1<n && eq(id[l],id[r+1])){
    			++r;
    			tmp.pb(id[r]);
    			tmp_time+=t[id[r]];
    		}
    		For(i,tmp.size()){
    			int x=tmp[i];

    			int t1=prv_tim+t[x],t2=prv_tim+tmp_time;
    			mxsc[x]=p[x]*(1.0-((ld)c*(t1))/((ld)T));
    			mnsc[x]=p[x]*(1.0-((ld)c*(t2))/((ld)T));
    // 			trace(x,p[x],mnsc[x],c,t1,t2,mxsc[x]);
    // 			int p1=p[x],p2=p[y];
    // 			ld currrr=(p2-p1)*T;
    // 			currrr/=((ld) p2*t2-p1*t1);
    // 			c=min(c,currrr);
    		}
    		prv_tim+=tmp_time;
    		l=r+1;
    	}
    	sort(id,id+n,cmp2);
    	ld mx=0;
    	int j=0;
    	For(i,n){
    	    while(p[id[i]]!=p[id[j]]){
    	        mx=max(mx,mxsc[id[j]]);
    	        ++j;
    	    }
    	    if (gt(mx,mnsc[id[i]])){
    	        sol=false;
    	        break;
    	    }

    	   // mx=max(mx,mxsc[id[i]]);
    	}
    	if (sol){
    	    ans=c;
    	    low=c;
    	}
    	else{
    	    high=c;
    	}
	}

	d1(ans);

}
signed main(){
    // Use "set_name".max_load_factor(0.25);"set_name".reserve(512); with unordered set
    // Uncomment codechef for large input files. Doesn't work on codeforces.
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
    fio;
    cout<<fixed<<setprecision(25);
    int t=1;
    // read(t);
    while(t--) {
        solve();
    }
}


#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <unordered_map>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

int const MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-12;
ll INF = LLONG_MAX / 10;

bool unko(i_i l, i_i r) {
	return (ll)l.first * r.second < (ll)r.first * l.second;
}

int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) scanf("%d", &a[i]);
	vector<int> A = a;
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	int M = A.size();
	vector<int> t(N);
	rep(i, N) scanf("%d", &t[i]);
	ll T = 0;
	rep(i, N) T += t[i];
	vector<i_i> at(N);
	rep(i, N) at[i] = i_i(a[i], t[i]);
	sort(at.rbegin(), at.rend(), unko);
	rep(i, N) a[i] = at[i].first, t[i] = at[i].second;
	vector<ll> sum(N + 1);
	rep(i, N) sum[i + 1] = sum[i] + t[i];
	vector<int> l(N), r(N);
	for (int i = 0; i + 1 < N; i++) {
		l[i + 1] = l[i];
		if (unko(at[i + 1], at[i])) l[i + 1] = i + 1;
	}
	r[N - 1] = N;
	for (int i = N - 1; i - 1 >= 0; i--) {
		r[i - 1] = r[i];
		if (unko(at[i], at[i - 1])) r[i - 1] = i;
	}
	double lb = 0, ub = 1;
	rep(_t, 50) {
		double mid = (lb + ub) / 2;
		map<int, double> mi, ma;
		rep(i, N) {
			double x = a[i] * (1 - mid * (sum[l[i]] + t[i]) / T);
			if (ma.count(a[i])) ma[a[i]] = max(ma[a[i]], x);
			else ma[a[i]] = x;
			x = a[i] * (1 - mid * sum[r[i]] / T);
			if (mi.count(a[i])) mi[a[i]] = min(mi[a[i]], x);
			else mi[a[i]] = x;
		}
		bool ok = true;
		rep(j, M - 1) if (ma[A[j]] > mi[A[j + 1]]) ok = false;
		if (ok) lb = mid;
		else ub = mid;
	}
	printf("%.15f\n", lb);
}


#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <unordered_map>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

int const MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-12;
ll INF = LLONG_MAX / 10;

bool unko(i_i l, i_i r) {
	return (ll)l.first * r.second < (ll)r.first * l.second;
}

int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) scanf("%d", &a[i]);
	vector<int> A = a;
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	int M = A.size();
	vector<int> t(N);
	rep(i, N) scanf("%d", &t[i]);
	ll T = 0;
	rep(i, N) T += t[i];
	vector<i_i> at(N);
	rep(i, N) at[i] = i_i(a[i], t[i]);
	sort(at.rbegin(), at.rend(), unko);
	rep(i, N) a[i] = at[i].first, t[i] = at[i].second;
	vector<int> id(N);
	rep(i, N) id[i] = lower_bound(A.begin(), A.end(), a[i]) - A.begin();
	vector<ll> sum(N + 1);
	rep(i, N) sum[i + 1] = sum[i] + t[i];
	vector<int> l(N), r(N);
	for (int i = 0; i + 1 < N; i++) {
		l[i + 1] = l[i];
		if (unko(at[i + 1], at[i])) l[i + 1] = i + 1;
	}
	r[N - 1] = N;
	for (int i = N - 1; i - 1 >= 0; i--) {
		r[i - 1] = r[i];
		if (unko(at[i], at[i - 1])) r[i - 1] = i;
	}
	double lb = 0, ub = 1;
	rep(_t, 50) {
		double mid = (lb + ub) / 2;
		vector<double> mi(M, DBL_MAX), ma(M, -DBL_MIN);
		rep(i, N) {
			int j = id[i];
			double x = a[i] * (1 - mid * (sum[l[i]] + t[i]) / T);
			ma[j] = max(ma[j], x);
			x = a[i] * (1 - mid * sum[r[i]] / T);
			mi[j] = min(mi[j], x);
		}
		bool ok = true;
		rep(j, M - 1) if (ma[j] > mi[j + 1]) ok = false;
		if (ok) lb = mid;
		else ub = mid;
	}
	printf("%.15f\n", lb);
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define Rep(i,a) for(int i = 0; i < a; i ++)
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#define mp(a,b) make_pair(a,b)
const int N = 2e5 + 10;
const double eps = 1e-8;
int n, p[N]; pii a[N];
int t[N];
LL t1[N], t2[N], s[N]; int id[N];
inline bool cmp(const int &a, const int &b) { return 1LL * p[a] * t[b] > 1LL * p[b] * t[a]; }
bool check(double c) {
	double mx = -1e9; int j = 1;
	rep(i,1,n) {
		while (j <= n && p[j] < p[i]) { mx = max(mx, p[j] - c * p[j] * t1[j] / s[n]); j++; }
		if (mx > p[i] - c * p[i] * t2[i] / s[n]) return false;
	}
	return true;
}
int main() {
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",p + i);
	rep(i,1,n) scanf("%d",t + i);
	rep(i,1,n) a[i] = mp(p[i], t[i]);
	sort(a + 1, a + n + 1);
	rep(i,1,n) p[i] = a[i].first, t[i] = a[i].second;
	rep(i,1,n) id[i] = i;
	sort(id + 1, id + n + 1, cmp);
	rep(i,1,n) s[i] = s[i - 1] + t[id[i]];
	for(int i = 1, j; i <= n; i = j) {
		j = i; while (j <= n && !cmp(id[i], id[j]) && !cmp(id[j], id[i])) j++;
		rep(k,i,j - 1) t1[id[k]] = s[i - 1] + t[id[k]], t2[id[k]] = s[j - 1];
	}
	double l = 0, r = 1; int t = 0;
	while ( l + eps < r && t <= 100) {
		double mid = (l + r) / 2;
		if (check(mid)) l = mid; else r = mid;
	}
	printf("%.9lf\n",(l + r) / 2);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define Rep(i,a) for(int i = 0; i < a; i ++)
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#define mp(a,b) make_pair(a,b)
const int N = 2e5 + 10;
const double eps = 1e-8;
int n, p[N]; pii a[N];
LL t[N], t1[N], t2[N]; int id[N];
inline bool cmp(const int &a, const int &b) { return (1LL * p[a] * t[b] > 1LL * p[b] * t[a]); }

LL s[N];
bool check(double c) {
	double mx = -1e9; int j = 1;
	rep(i,1,n) {
		while (j <= n && p[j] < p[i]) { mx = max(mx, p[j] - c * p[j] * t1[j] / s[id[n]]); j++; }
		if (mx > p[i] - c * p[i] * t2[i] / s[id[n]]) return false;
	}
	return true;
}

int main() {
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",p + i);
	rep(i,1,n) scanf("%lld",t + i);
	rep(i,1,n) a[i] = mp(p[i], (int)t[i]);
	sort(a + 1, a + n + 1);
	rep(i,1,n) p[i] = a[i].first, t[i] = a[i].second;
	rep(i,1,n) id[i] = i;
	sort(id + 1, id + n + 1, cmp);
	rep(i,1,n) s[i] = s[i - 1] + t[id[i]];
	for(int i = 1, j; i <= n; i = j) {
		j = i; while (j <= n && !cmp(id[i], id[j]) && !cmp(id[j], id[i])) j++;
		rep(k,i,j - 1) t1[id[k]] = s[i - 1] + t[id[k]], t2[id[k]] = s[j - 1];
	}
	double l = 0, r = 1; int t = 0;
	while ( l + eps < r && t <= 100) {
		double mid = (l + r) / 2;
		if (check(mid)) l = mid; else r = mid;
	}
	printf("%.9lf\n",(l + r) / 2);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;

const int MN = 200010;

int N;
ll T;
pii P[MN];
bool cmp(pii a, pii b) {
    if(1LL * a.second * b.first != 1LL * b.second * a.first) return 1LL * a.second * b.first < 1LL * b.second * a.first;
    else return a.first < b.first;
}
vector<pii> ord;

lf L[MN], R[MN];

bool f(lf x) {
    ll sum = 0;
    ll cum = 0;
    int s = 0;
    for(int i = 0; i < N; i++) {
        cum += P[i].second;
        if(i == N - 1 || 1LL * P[i].second * P[i + 1].first != 1LL * P[i + 1].second * P[i].first) {
            for(int j = s; j <= i; j++) {
                R[j] = (lf)P[j].first * (1 - x * (sum + P[j].second) / T);
                L[j] = (lf)P[j].first * (1 - x * cum / T);
            }

            s = i + 1;
            sum = cum;
        }
    }

    for(int i = 1; i < N; i++) {
        int idx1 = ord[i - 1].second;
        int idx2 = ord[i].second;

        if(P[idx1].first != P[idx2].first && R[idx1] > L[idx2]) return false;
    }
    return true;
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i].first);
    }
    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i].second);
        T += P[i].second;
    }

    sort(P, P + N, cmp);

    for(int i = 0; i < N; i++) {
        ord.push_back({ P[i].first, i });
    }
    sort(ord.begin(), ord.end());

    lf s = 0, e = 1;
    for(int n = 0; n < 30; n++) {
        lf m = (s + e) / 2;

        if(f(m)) s = m;
        else e = m;
    }

    cout << fixed;
    cout.precision(20);
    cout << s;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double lf;
typedef pair<int, int> pii;

const int MN = 200010;

int N;
ll T;
pii P[MN];
bool cmp(pii a, pii b) {
    if(1LL * a.second * b.first != 1LL * b.second * a.first) return 1LL * a.second * b.first < 1LL * b.second * a.first;
    else return a.first < b.first;
}
vector<pii> ord;

lf L[MN], R[MN];

bool f(lf x) {
    ll sum = 0;
    ll cum = 0;
    int s = 0;
    for(int i = 0; i < N; i++) {
        cum += P[i].second;
        if(i == N - 1 || 1LL * P[i].second * P[i + 1].first != 1LL * P[i + 1].second * P[i].first) {
            for(int j = s; j <= i; j++) {
                R[j] = (lf)P[j].first * (1 - x * (sum + P[j].second) / T);
                L[j] = (lf)P[j].first * (1 - x * cum / T);
            }

            s = i + 1;
            sum = cum;
        }
    }

    s = 0;
    lf mx = -1;
    for(int i = 0; i < N; i++) {
        if(i == N - 1 || ord[i].first != ord[i + 1].first) {
            for(int j = s; j <= i; j++) {
               if(mx > L[ ord[j].second ] + 1e-12) return false;
            }
            for(int j = s; j <= i; j++) {
                mx = max(mx, R[ ord[j].second ]);
            }
            s = i + 1;
        }
    }
    return true;
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i].first);
    }
    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i].second);
        T += P[i].second;
    }

    sort(P, P + N, cmp);

    for(int i = 0; i < N; i++) {
        ord.push_back({ P[i].first, i });
    }
    sort(ord.begin(), ord.end());

    lf s = 0, e = 1;
    for(int n = 0; n < 30; n++) {
        lf m = (s + e) / 2;

        if(f(m)) s = m;
        else e = m;
    }

    cout << fixed;
    cout.precision(20);
    cout << s;
}


#include<bits/stdc++.h>
using namespace std;

typedef double lf;
typedef pair<int, int> pii;

const int MN = 200010;

int N, T;
pii P[MN];
bool cmp(pii a, pii b) {
    if(1LL * a.second * b.first != 1LL * b.second * a.first) return 1LL * a.second * b.first < 1LL * b.second * a.first;
    else return a.first < b.first;
}
vector<pii> ord, tmp;

lf L[MN], R[MN], S[MN];

bool f(lf x) {
    lf sum = 0;
    lf cum = 0;
    int s = 0;
    for(int i = 0; i < N; i++) {
        cum += P[i].second;
        if(i == N - 1 || 1LL * P[i].second * P[i + 1].first != 1LL * P[i + 1].second * P[i].first) {
            tmp.clear();
            for(int j = s; j <= i; j++) {
                R[j] = (lf)P[j].first * (1 - x * (sum + P[j].second) / T);
                L[j] = (lf)P[j].first * (1 - x * (sum + cum) / T);

                tmp.push_back({ P[j].first, j });
            }

            sort(tmp.begin(), tmp.end());

            lf mx = -1;
            for(int j = 0; j < tmp.size(); j++) {
                int idx = tmp[j].second;
                if(mx > L[idx]) return false;
                mx = R[idx];
            }

            s = i + 1;
            sum += cum;
        }
    }

    sum = 0;
    for(int i = 0; i < N; i++) {
        sum += P[i].second;
        S[i] = (lf)P[i].first * (1 - x * sum / T);
    }

    lf mx = -1;
    for(int i = 0; i < N; i++) {
        int idx = ord[i].second;

        if(mx > S[idx]) return false;
        mx = S[idx];
    }
    return true;
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i].first);
    }
    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i].second);
        T += P[i].second;
    }

    sort(P, P + N, cmp);

    for(int i = 0; i < N; i++) {
        ord.push_back({ P[i].first, i });
    }
    sort(ord.begin(), ord.end());

    lf s = 0, e = 1;
    for(int n = 0; n < 30; n++) {
        lf m = (s + e) / 2;

        if(f(m)) s = m;
        else e = m;
    }

    cout << fixed;
    cout.precision(20);
    cout << s;
}


#include<bits/stdc++.h>
using namespace std;

typedef double lf;
typedef pair<int, int> pii;

const int MN = 200010;

int N, T;
pii P[MN];
bool cmp(pii a, pii b) {
    if(1LL * a.second * b.first != 1LL * b.second * a.first) return 1LL * a.second * b.first < 1LL * b.second * a.first;
    else return a.first < b.first;
}
vector<pii> ord, tmp;

lf L[MN], R[MN];

bool f(lf x) {
    lf sum = 0;
    lf cum = 0;
    int s = 0;
    for(int i = 0; i < N; i++) {
        cum += P[i].second;
        if(i == N - 1 || 1LL * P[i].second * P[i + 1].first != 1LL * P[i + 1].second * P[i].first) {
            tmp.clear();
            for(int j = s; j <= i; j++) {
                R[j] = (lf)P[j].first * (1 - x * (sum + P[j].second) / T);
                L[j] = (lf)P[j].first * (1 - x * cum / T);

                tmp.push_back({ P[j].first, j });
            }

            sort(tmp.begin(), tmp.end());

            lf mx = -1;
            for(int j = 0; j < tmp.size(); j++) {
                int idx = tmp[j].second;
                if(mx > L[idx] + 1e-9) return false;
                mx = R[idx];
            }

            s = i + 1;
            sum = cum;
        }
    }

    for(int i = 1; i < N; i++) {
        int idx1 = ord[i - 1].second;
        int idx2 = ord[i].second;

        if(1LL * P[idx1].second * P[idx2].first != 1LL * P[idx2].second * P[idx1].first) {
            if(R[idx1] > L[idx2]) return false;
        }
    }
    return true;
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i].first);
    }
    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i].second);
        T += P[i].second;
    }

    sort(P, P + N, cmp);

    for(int i = 0; i < N; i++) {
        ord.push_back({ P[i].first, i });
    }
    sort(ord.begin(), ord.end());

    lf s = 0, e = 1;
    for(int n = 0; n < 30; n++) {
        lf m = (s + e) / 2;

        if(f(m)) s = m;
        else e = m;
    }

    cout << fixed;
    cout.precision(20);
    cout << s;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;

const int MN = 200010;

int N;
ll T;
pii P[MN];
bool cmp(pii a, pii b) {
    if(1LL * a.second * b.first != 1LL * b.second * a.first) return 1LL * a.second * b.first < 1LL * b.second * a.first;
    else return a.first < b.first;
}
vector<pii> ord, tmp;

lf L[MN], R[MN];

bool f(lf x) {
    ll sum = 0;
    ll cum = 0;
    int s = 0;
    for(int i = 0; i < N; i++) {
        cum += P[i].second;
        if(i == N - 1 || 1LL * P[i].second * P[i + 1].first != 1LL * P[i + 1].second * P[i].first) {
            tmp.clear();
            for(int j = s; j <= i; j++) {
                R[j] = (lf)P[j].first * (1 - x * (sum + P[j].second) / T);
                L[j] = (lf)P[j].first * (1 - x * cum / T);

                tmp.push_back({ P[j].first, j });
            }

            sort(tmp.begin(), tmp.end());

            lf mx = -1;
            for(int j = 0; j < tmp.size(); j++) {
                int idx = tmp[j].second;
                if(mx > L[idx] + 1e-9) return false;
                mx = R[idx];
            }

            s = i + 1;
            sum = cum;
        }
    }

    for(int i = 1; i < N; i++) {
        int idx1 = ord[i - 1].second;
        int idx2 = ord[i].second;

        if(1LL * P[idx1].second * P[idx2].first != 1LL * P[idx2].second * P[idx1].first) {
            if(R[idx1] > L[idx2]) return false;
        }
    }
    return true;
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i].first);
    }
    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i].second);
        T += P[i].second;
    }

    sort(P, P + N, cmp);

    for(int i = 0; i < N; i++) {
        ord.push_back({ P[i].first, i });
    }
    sort(ord.begin(), ord.end());

    lf s = 0, e = 1;
    for(int n = 0; n < 30; n++) {
        lf m = (s + e) / 2;

        if(f(m)) s = m;
        else e = m;
    }

    cout << fixed;
    cout.precision(20);
    cout << s;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
struct rational {
    int b, a;
    bool operator<(const rational &p) const {
        return (llong)b * p.a > (llong)p.b * a;
    }
} pt[150000];

map<rational, vector<rational>> mp;

llong sum = 0;
const int inf = 1e9;
int check(ld c) {
    map<int, pair<ld, ld>> mx;
    llong asum = 0;
    for (auto &v : mp) {
        llong tsum = 0;
        ld d, u;
        for (rational i : v.second) {
            tsum += i.a;
        }
        for (rational i : v.second) {
            u = i.b * (1.0 - c * (asum + i.a) / sum);
            d = i.b * (1.0 - c * (asum + tsum) / sum);
            if (mx.find(i.b) != mx.end()) {
                mx[i.b].first = min(mx[i.b].first, d);
                mx[i.b].second = max(mx[i.b].second, u);
            }
            else mx[i.b] = { d, u };
        }
        asum += tsum;
    }
    auto it1 = mx.begin();
    auto it2 = ++mx.begin();
    while (it2 != mx.end()) {
        if (it1->second.second > it2->second.first) return 0;
        ++it1;
        ++it2;
    }
    return 1;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> pt[i].b;
	for (int i = 0; i < n; ++i) cin >> pt[i].a, sum += pt[i].a;
	for (int i = 0; i < n; ++i) mp[pt[i]].push_back(pt[i]);

	int s = 0, e = inf;
	while (s < e) {
        int m = (s + e + 1) / 2;
        if (check(m / (ld)inf)) s = m;
        else e = m - 1;
	}
	printf("%d.", s / inf);
	for (int i = inf / 10; i > 0; i /= 10) {
        printf("%d", s / i % 10);
	}
	printf("\n");
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
struct rational {
    int b, a;
    bool operator<(const rational &p) const {
        return (llong)b * p.a > (llong)p.b * a;
    }
} pt[150000];

map<rational, vector<rational>> mp;

llong sum = 0;
const int inf = 1e9;
int check(ld c) {
    map<int, pair<ld, ld>> mx;
    llong asum = 0;
    for (auto &v : mp) {
        llong tsum = 0;
        ld d, u;
        for (rational i : v.second) {
            tsum += i.a;
        }
        for (rational i : v.second) {
            u = i.b * (1.0 - c * (asum + i.a) / sum);
            d = i.b * (1.0 - c * (asum + tsum) / sum);
            if (mx.find(i.b) != mx.end()) {
                mx[i.b].first = min(mx[i.b].first, d);
                mx[i.b].second = max(mx[i.b].second, u);
            }
            else mx[i.b] = { d, u };
        }
        asum += tsum;
    }
    auto it1 = mx.begin();
    auto it2 = ++mx.begin();
    while (it2 != mx.end()) {
        if (it1->second.second > it2->second.first) return 0;
        ++it1;
        ++it2;
    }
    return 1;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> pt[i].b;
	for (int i = 0; i < n; ++i) cin >> pt[i].a, sum += pt[i].a;
	for (int i = 0; i < n; ++i) mp[pt[i]].push_back(pt[i]);

	int s = 0, e = inf;
	while (s < e) {
        int m = (s + e + 1) / 2;
        if (check(m / (ld)inf)) s = m;
        else e = m - 1;
	}
	printf("%d\n", s);
	printf("%d.", s / inf);
	for (int i = inf / 10; i > 0; i /= 10) {
        printf("%d", s / i % 10);
	}
	printf("\n");
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <fstream>

using namespace std;

#define LL long long
#define N 200002
#define M 400100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ll, md, ls
#define rson md+1, rr, rs
#define mod 1000000007
#define inf 0x3f3f3f3f
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define uLL unsigned long long
#define ui unsigned int
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define G(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<LL,int>
#define pb push_back
#define MP make_pair
LL gcd(LL x,LL y){
    while(y){
        LL t = x % y;
        x = y;
        y = t;
    }
    return x;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

ui read()
{
    ui x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

struct node
{
    int p, t;
    double mx, mi;

    bool operator < (const node &x) const
    {
        return 1LL * t * x.p < 1LL * p * x.t;
    }
}pro[N];

int n, a[N];
LL T = 0;

bool cmp(int x, int y)
{
    return pro[x].p == pro[y].p ? x > y : pro[x].p < pro[y].p;
}

bool check(double mid)
{

    LL tmp = 0; int pre = 1;
    for(int i = 2; i <= n + 1; i++)
    {
        if(i > n || pro[i - 1] < pro[i])
        {
            for(int j = pre; j < i; j++) pro[j].mx = (double)pro[j].p * (1.0 - mid * (tmp + pro[j].t) / T);
            for(int j = pre; j < i; j++) tmp += pro[j].t;
            for(int j = pre; j < i; j++) pro[j].mi = (double)pro[j].p * (1.0 - mid * tmp / T);
            pre = i;
        }
    }

    pre = 1;
    double mx = 0;
    for(int i = 2; i <= n; i++)
    {
        if(pro[a[i]].p != pro[a[i - 1]].p)
        {
            for(int j = pre; j < i; j++) chkmax(mx, pro[a[j]].mx);
            pre = i;
        }
        if(pro[a[i]].mi + eps < mx) return 0;

    }
    return 1;

}

int main()
{
    n = read();
    for(int i = 1; i <= n; i++)
        a[i] = i,  pro[i].p = read();
    for(int i = 1; i <= n; i++)
        pro[i].t = read(), T += pro[i].t;

    sort(pro + 1, pro + 1 + n);
    sort(a + 1, a + 1 + n, cmp);

    double l = 0, r = 1;
    for(int i = 0; i <= 50; i++)
    {
        double mid = (l + r) * 0.5;

        if(check(mid)) l = mid;
        else r = mid;
    }

    printf("%.10lf\n",(l + r) * 0.5);

    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <fstream>

using namespace std;

#define LL long long
#define N 200002
#define M 400100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ll, md, ls
#define rson md+1, rr, rs
#define mod 1000000007
#define inf 0x3f3f3f3f
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define uLL unsigned long long
#define ui unsigned int
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define G(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<LL,int>
#define pb push_back
#define MP make_pair
LL gcd(LL x,LL y){
    while(y){
        LL t = x % y;
        x = y;
        y = t;
    }
    return x;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

ui read()
{
    ui x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

struct node
{
    int p, t;
    double mx, mi;

    bool operator < (const node &x) const
    {
        return 1LL * t * x.p < 1LL * p * x.t;
    }
}pro[N];

int n, a[N];
LL T = 0;

bool cmp(int x, int y)
{
    return pro[x].p == pro[y].p ? x > y : pro[x].p < pro[y].p;
}

bool check(double mid)
{

    LL tmp = 0; int pre = 1;
    for(int i = 2; i <= n + 1; i++)
    {
        if(i > n || a[i - 1] < a[i] || a[i] < a[i - 1])
        {
            for(int j = pre; j < i; j++) pro[j].mx = (double)pro[j].p * (1.0 - mid * (tmp + pro[j].t) / T);
            for(int j = pre; j < i; j++) tmp += pro[j].t;
            for(int j = pre; j < i; j++) pro[j].mi = (double)pro[j].p * (1.0 - mid * tmp / T);
            pre = i;
        }
    }

    pre = 1;
    double mx = 0;
    for(int i = 2; i <= n; i++)
    {
        if(pro[a[i]].p != pro[a[i - 1]].p)
        {
            for(int j = pre; j < i; j++) chkmax(mx, pro[a[j]].mx);
            pre = i;
        }
        if(pro[a[i]].mi + eps < mx) return 0;

    }
    return 1;

}

int main()
{
    n = read();
    for(int i = 1; i <= n; i++)
        a[i] = i,  pro[i].p = read();
    for(int i = 1; i <= n; i++)
        pro[i].t = read(), T += pro[i].t;

    sort(pro + 1, pro + 1 + n);
    sort(a + 1, a + 1 + n, cmp);

    double l = 0, r = 1;
    for(int i = 0; i <= 50; i++)
    {
        double mid = (l + r) * 0.5;

        if(check(mid)) l = mid;
        else r = mid;
    }

    printf("%.10lf\n",(l + r) * 0.5);

    return 0;
}


#include<bits/stdc++.h>

const double eps = 1e-9;
inline int sig(double p){return (p > eps) - (p < -eps);}

struct frac{
	int x, y;

	frac (int x = 0, int y = 0):x(x), y(y){}

	bool operator < (const frac &f)const{
		return 1ll * x * f.y > 1ll * y * f.x;
	}

	bool operator == (const frac &f)const{
		return 1ll * x * f.y == 1ll * y * f.x;
	}
};

struct func{
	double k, b;

	func (double k = 0, double b = 0):k(k), b(b){}

	bool operator < (const func &f)const{
		return k < f.k || b < f.b;
	}

	double solve(const func &f)const{
		if (!sig(k - f.k)) return 10;
		double ret = (f.b - b) / (k - f.k);
		return sig(ret) > 0 ? ret : 10;
	}
};

const int N = 150010;
typedef long long ll;
typedef std::pair <func, func> pff;

int p[N], t[N];
frac pp[N];

int main(){
	int n;
	ll T = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i){
		scanf("%d", &p[i]);
	}
	for (int i = 0; i < n; ++ i){
		scanf("%d", &t[i]);
		T += t[i];
		pp[i] = frac (p[i], t[i]);
	}
	std::sort(pp, pp + n);
	std::map <int, pff> Hash;
	ll c1 = 0, c2 = 0;
	for (int i = 0, j = 0; i < n; c1 = c2){
		while (j < n && pp[j] == pp[i]){
			c2 += pp[j ++].y;
		}
		while (i < j){
			func maxfunc(-1.0 * (c1 + pp[i].y) * pp[i].x / T, pp[i].x);
			func minfunc(-1.0 * c2 * pp[i].x / T, pp[i].x);
			if (!Hash.count(pp[i].x)){
				Hash[pp[i].x] = {minfunc, maxfunc};
			}
			else{
				auto &u = Hash[pp[i].x];
				u.first = std::min(u.first, minfunc);
				u.second = std::max(u.second, maxfunc);
			}
			++ i;
		}
	}
	double ans = 1.0;
	for (auto u = Hash.begin(); u != Hash.end(); ){
		auto v = u ++;
		if (u == Hash.end()) break;
		ans = std::min(ans, (v -> second).second.solve((u -> second).first));
	}
	printf("%.10lf\n", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define N ((ll)151*1000)

ll n,p[N],t[N],id[N],min_t[N],max_t[N],all_t;

bool cmp(ll x,ll y){return p[x]*t[y]>p[y]*t[x];}

bool cmp2(ll x,ll y){return p[x]<p[y];}

bool check(ld c)
{
	ld best=p[id[0]]*((ld)1-c*min_t[id[0]]/all_t);
	for(int i=1;i<n;i++)
	{
		ld now=(ld)p[id[i]]*((ld)1-c*max_t[id[i]]/all_t);
		if(now<best)return 0;
		best=max(best,(ld)p[id[i]]*((ld)1-c*min_t[id[i]]/all_t));
	}
	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)cin>>p[i];
	for(int i=0;i<n;i++)cin>>t[i],id[i]=i,all_t+=t[i];
	sort(id,id+n,cmp);
	ll sum=0,now=0,j=0;
	for(int i=0;i<n;i++)
	{
		if(i && p[id[i]]*t[id[i-1]]!=p[id[i-1]]*t[id[i]])
		{
			sum+=now;now=0;
			while(j<i)max_t[id[j]]=sum,j++;
		}
		now+=t[id[i]];
		min_t[id[i]]=sum+t[id[i]];
	}
	sum+=now;
	while(j<n)max_t[id[j]]=sum,j++;
	sort(id,id+n,cmp2);
	ld l=0,r=1;
	for(int i=0;i<50;i++)
	{
		ld mid=(l+r)/2;
		if(check(mid))l=mid;
		else r=mid;
	}
	cout<<fixed<<setprecision(16)<<l<<"\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define N ((ll)151*1000)

ll n,p[N],t[N],id[N],min_t[N],max_t[N],all_t;

bool cmp(ll x,ll y){return p[x]*t[y]>p[y]*t[x];}

bool cmp2(ll x,ll y){return p[x]<p[y];}

bool check(ld c)
{
	ld prt_best=p[id[0]]*((ld)1-c*min_t[id[0]]/all_t);
	ld best=0;
	for(int i=1;i<n;i++)
	{
		if(p[id[i]]!=p[id[i-1]])best=max(best,prt_best);
		ld now=(ld)p[id[i]]*((ld)1-c*max_t[id[i]]/all_t);
		if(now<best)return 0;
		prt_best=max(best,(ld)p[id[i]]*((ld)1-c*min_t[id[i]]/all_t));
	}
	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)cin>>p[i];
	for(int i=0;i<n;i++)cin>>t[i],id[i]=i,all_t+=t[i];
	sort(id,id+n,cmp);
	ll sum=0,now=0,j=0;
	for(int i=0;i<n;i++)
	{
		if(i && p[id[i]]*t[id[i-1]]!=p[id[i-1]]*t[id[i]])
		{
			sum+=now;now=0;
			while(j<i)max_t[id[j]]=sum,j++;
		}
		now+=t[id[i]];
		min_t[id[i]]=sum+t[id[i]];
	}
	sum+=now;
	while(j<n)max_t[id[j]]=sum,j++;
	sort(id,id+n,cmp2);
	ld l=0,r=1;
	for(int i=0;i<50;i++)
	{
		ld mid=(l+r)/2;
		if(check(mid))l=mid;
		else r=mid;
	}
	cout<<fixed<<setprecision(16)<<l<<"\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define N ((ll)151*1000)

ll n,p[N],t[N],id[N],min_t[N],max_t[N],all_t;

bool cmp(ll x,ll y){return p[x]*t[y]>p[y]*t[x];}

bool cmp2(ll x,ll y){return p[x]<p[y];}

bool check(ld c)
{
	ld prt_best=p[id[0]]*((ld)1-c*min_t[id[0]]/all_t);
	ld best=0;
	for(int i=1;i<n;i++)
	{
		if(p[id[i]]!=p[id[i-1]])best=max(best,prt_best),prt_best=0;
		ld now=(ld)p[id[i]]*((ld)1-c*max_t[id[i]]/all_t);
		if(now<best)return 0;
		prt_best=max(prt_best,(ld)p[id[i]]*((ld)1-c*min_t[id[i]]/all_t));
	}

	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)cin>>p[i];
	for(int i=0;i<n;i++)cin>>t[i],id[i]=i,all_t+=t[i];
	sort(id,id+n,cmp);
	ll sum=0,now=0,j=0;
	for(int i=0;i<n;i++)
	{
		if(i && p[id[i]]*t[id[i-1]]!=p[id[i-1]]*t[id[i]])
		{
			sum+=now;now=0;
			while(j<i)max_t[id[j]]=sum,j++;
		}
		now+=t[id[i]];
		min_t[id[i]]=sum+t[id[i]];
	}
	sum+=now;
	while(j<n)max_t[id[j]]=sum,j++;
	sort(id,id+n,cmp2);
	ld l=0,r=1;
	for(int i=0;i<50;i++)
	{
		ld mid=(l+r)/2;
		if(check(mid))l=mid;
		else r=mid;
	}
	cout<<fixed<<setprecision(16)<<l<<"\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 200000;
int pi[N], ti[N], ord1[N], ord2[N], T;
int comp1(int a, int b)
{
    return 1ll * ti[a] * pi[b] < 1ll * ti[b] * pi[a];
}
int comp2(int a, int b)
{
    return pi[a] < pi[b];
}
double mn[N], mx[N];
int check(double c)
{
    double s = 0;
    for (int p = 1, q = 1; p <= n; p = q + 1, q = p)
    {
        while (q < n && 1ll * ti[ord1[q]] * pi[ord1[q + 1]] == 1ll * ti[ord1[q + 1]] * pi[ord1[q]])
            q ++;
        for (int r = p; r <= q; ++ r)
        {
            int i = ord1[r];
            mx[i] = pi[i] * (1 - c * (s + ti[i]) / T);
        }
        for (int r = p; r <= q; ++ r)
        {
            int i = ord1[r];
            s += ti[i];
        }
        for (int r = p; r <= q; ++ r)
        {
            int i = ord1[r];
            mn[i] = pi[i] * (1 - c * s / T);
        }
    }
    double tmp = 0;
    for (int p = 1, q = 1; p <= n; p = q + 1, q = p)
    {
        while (pi[ord2[q]] == pi[ord2[q + 1]]) q ++;
        for (int r = p; r <= q; ++ r)
        {
            int i = ord2[r];
            if (mn[i] < tmp) return 0;
        }
        for (int r = p; r <= q; ++ r)
        {
            int i = ord2[r];
            tmp = max(tmp, mx[i]);
        }
    }
    return 1;
}
int main()
{
    ios :: sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; ++ i) cin >> pi[i];
    for (int i = 1; i <= n; ++ i) cin >> ti[i], T += ti[i];
    for (int i = 1; i <= n; ++ i) ord1[i] = ord2[i] = i;
    sort(ord1 + 1, ord1 + n + 1, comp1);
    sort(ord2 + 1, ord2 + n + 1, comp2);
    double l = 0, r = 1;
    while (1.0 * clock() / CLOCKS_PER_SEC < 2)
    {
        double m = (l + r) / 2;
        if (check(m)) l = m; else r = m;
    }
    printf("%.10lf\n", l);
}


#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 200000;
#define LL long long
int pi[N], ti[N], ord1[N], ord2[N]; LL T;
int comp1(int a, int b)
{
    return 1ll * ti[a] * pi[b] < 1ll * ti[b] * pi[a];
}
int comp2(int a, int b)
{
    return pi[a] < pi[b];
}
double mn[N], mx[N];
int check(double c)
{
    double s = 0;
    for (int p = 1, q = 1; p <= n; p = q + 1, q = p)
    {
        while (q < n && 1ll * ti[ord1[q]] * pi[ord1[q + 1]] == 1ll * ti[ord1[q + 1]] * pi[ord1[q]])
            q ++;
        for (int r = p; r <= q; ++ r)
        {
            int i = ord1[r];
            mx[i] = pi[i] * (1 - c * (s + ti[i]) / T);
        }
        for (int r = p; r <= q; ++ r)
        {
            int i = ord1[r];
            s += ti[i];
        }
        for (int r = p; r <= q; ++ r)
        {
            int i = ord1[r];
            mn[i] = pi[i] * (1 - c * s / T);
        }
    }
    double tmp = 0;
    for (int p = 1, q = 1; p <= n; p = q + 1, q = p)
    {
        while (pi[ord2[q]] == pi[ord2[q + 1]]) q ++;
        for (int r = p; r <= q; ++ r)
        {
            int i = ord2[r];
            if (mn[i] < tmp) return 0;
        }
        for (int r = p; r <= q; ++ r)
        {
            int i = ord2[r];
            tmp = max(tmp, mx[i]);
        }
    }
    return 1;
}
int main()
{
    ios :: sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; ++ i) cin >> pi[i];
    for (int i = 1; i <= n; ++ i) cin >> ti[i], T += ti[i];
    for (int i = 1; i <= n; ++ i) ord1[i] = ord2[i] = i;
    sort(ord1 + 1, ord1 + n + 1, comp1);
    sort(ord2 + 1, ord2 + n + 1, comp2);
    double l = 0, r = 1;
    while (1.0 * clock() / CLOCKS_PER_SEC < 2)
    {
        double m = (l + r) / 2;
        if (check(m)) l = m; else r = m;
    }
    printf("%.10lf\n", l);
}


#include<algorithm>
#include<iostream>
#include<cstdio>
#define MN 150000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,rt[MN+5],rk[MN+5],lt[MN+5];long long T[MN+5];
pair<int,int> s[MN+5];
bool cmp2(int x,int y){return s[x].first<s[y].first;}
bool cmp(pair<int,int> x,pair<int,int> y){return 1LL*x.first*y.second>1LL*y.first*x.second;}

bool Solve(double mid)
{
//	cout<<"Solve"<<mid<<endl;
	double mx=-1e18;
	for(int i=1,j;i<=n;i=j+1)
	{
		for(j=i+1;j<=n&&s[rk[j]].first==s[rk[i]].first;++j);--j;
		for(int k=i;k<=j;++k)
		{
			double c=s[rk[k]].first*(1-mid*T[rt[rk[k]]]/T[n]);
			if(c<mx) return false;
		//	cout<<rk[k]<<" "<<c<<" "<<s[rk[k]].first<<" "<<T[rt[rk[k]]]<<" "<<mx<<endl;
		}
		for(int k=i;k<=j;++k) mx=max(mx,s[rk[k]].first*(1-mid*(T[lt[rk[k]]-1]+s[rk[k]].second)/T[n]));
	}
	return true;
}

int main()
{
	n=read();
	for(int i=1;i<=n;++i) s[i].first=read(),rk[i]=i;
	for(int i=1;i<=n;++i) s[i].second=read();
	sort(s+1,s+n+1,cmp);sort(rk+1,rk+n+1,cmp2);
	for(int i=1;i<=n;++i) T[i]=T[i-1]+s[i].second;
	for(int i=1,j;i<=n;i=j+1)
	{
		for(j=i+1;j<=n&&1LL*s[j].second*s[i].first==1LL*s[i].second*s[j].first;++j);--j;
		for(int k=i;k<=j;++k) rt[k]=j,lt[k]=i;
	}
	double l=0,r=1,mid;
	for(int i=1;i<=100;++i)
	{
		mid=(l+r)/2.0;
		if(Solve(mid)) l=mid;
		else r=mid;
	}
	printf("%.10lf\n",(l+r)/2.0);
	return 0;
}


#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
using namespace std;
const double EPS = 1e-9;
int n;
long long tt, ts, te; //total time, time start, time end (used later)
long long P[150005], T[150005];
long long mT[150005], MT[150005];
int A[150005];
bool comp(int i, int j){
	return P[i]*T[j]>T[i]*P[j];
}
bool comp2(int i, int j){
	return P[i]<P[j];
}
int main() {
	cin.tie(NULL);
	ios::sync_with_stdio(0);
	cin>>n;
	f(i, n) cin>>P[i];
	f(i, n) {
		cin>>T[i];
		tt+=T[i];
		A[i] = i;
	}
	A[n] = n;
	sort(A, A+n, comp);
	T[n] = -1, P[n] = 1;
	int start = 0, end = 0;
	f(i, n){
		int x = A[i], y = A[i+1];
		te += T[x];
		if (P[x]*T[y]==T[x]*P[y]) end++;
		else {
			for (int j = start; j<=end; j++){
				x=A[j];
				mT[x] = ts+T[x];
				MT[x] = te;
			}
			ts=te;
			end++;
			start = end;
		}
	}
	sort (A, A+n, comp2);
	double lo = 0, hi = 1;
	while (hi - lo > EPS){
		double guess = (lo+hi)/2;
		bool fail = 0;
		double mini = 0, maxi = 0, tmpmaxi = 0;
		f(i, n){
			int x = A[i];
			mini = (1-guess*MT[x]/tt) * P[x];
			if (mini - maxi < -EPS) fail = 1;
			tmpmaxi = max(tmpmaxi, (1-guess*mT[x]/tt) * P[x]);
			if (P[A[i+1]] != P[A[i]]) maxi = tmpmaxi;
		}
		if (fail) hi = guess; else lo = guess;
	}
	cout<< setprecision(10) << fixed << hi <<endl;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair <int, int> ii;
typedef long double ld;

const int Maxn = 200005;

int n;
ii pt[Maxn];
ld T;
ld mnpoints[Maxn], mxpoints[Maxn];
int ind[Maxn];

bool Eq(const ii &a, const ii &b)
{
	return ll(a.first) * ll(b.second) == ll(b.first) * ll(a.second);
}

bool Less(const ii &a, const ii &b)
{
	if (ll(a.first) * ll(b.second) != ll(b.first) * ll(a.second))
		return ll(a.first) * ll(b.second) > ll(b.first) * ll(a.second);
	return a.first < b.first;
}

bool Less2(const int &a, const int &b)
{
	return pt[a].first > pt[b].first;
}

bool Paradox(ld c)
{
	ld tim = 0.0;
	for (int i = 0, j; i < n; i = j) {
		ld sum = 0.0l;
		j = i;
		while (j < n && Eq(pt[i], pt[j])) {
			sum += pt[j].second;
			j++;
		}
		j = i;
		while (j < n && Eq(pt[i], pt[j])) {
			mnpoints[j] = ld(pt[j].first) * (1.0l - c * (tim + sum) / T);
			mxpoints[j] = ld(pt[j].first) * (1.0l - c * (tim + ld(pt[j].second)) / T);
			j++;
		}
		tim += sum;
	}
	ld mn = 1e9l;
	for (int i = 0, j; i < n; i = j) {
		j = i;
		ld mymn = 1e9l;
		while (j < n && pt[ind[i]].first == pt[ind[j]].first) {
			if (mn < mxpoints[ind[j]]) return true;
			mymn = min(mymn, mnpoints[ind[j]]);
			j++;
		}
		mn = min(mn, mymn);
	}
	return false;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &pt[i].first);
	for (int i = 0; i < n; i++) {
		scanf("%d", &pt[i].second);
		T += pt[i].second;
	}
	sort(pt, pt + n, Less);
	for (int i = 0; i < n; i++)
		ind[i] = i;
	sort(ind, ind + n, Less2);
	ld lef = 0, rig = 1;
	for (int i = 0; i < 40; i++) {
		ld mid = (lef + rig) / 2.0l;
		if (Paradox(mid)) rig = mid;
		else lef = mid;
	}
	cout << fixed << setprecision(10) << lef << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB long double
const DB eps=0.000000000001;
int n,fl; LL T,tt,t;
DB l,r,mx,tmx,c;
struct O{
	LL p,t; DB l,r;
}a[150005];
bool cmp(O a,O b){
	return a.p*b.t==b.p*a.t?a.p<b.p:a.p*b.t>b.p*a.t;
}
bool cms(O a,O b){
	return a.p<b.p;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%lld",&a[i].p);
	for (int i=1;i<=n;++i) scanf("%lld",&a[i].t),T+=a[i].t;
	sort(a+1,a+n+1,cmp);
	for (int i=1,j;i<=n;i=j){
		tt=0;
		for (j=i;j<=n&&a[j].p*a[i].t==a[i].p*a[j].t;++j)
			tt+=a[j].t,a[j].l=-(DB)(t+a[j].t)*a[j].p/T;
		t+=tt;
		for (j=i;j<=n&&a[j].p*a[i].t==a[i].p*a[j].t;++j)
			a[j].r=-(DB)t*a[j].p/T;
	}
	sort(a+1,a+n+1,cms);
	l=0; r=1;
	while (r-l>0.00000000001){
		mx=0; c=(l+r)/2; fl=1;
		for (int i=1,j;i<=n;i=j){
			tmx=0;
			for (j=i;j<=n&&a[j].p==a[i].p;++j){
				if (a[i].r*c+a[i].p<mx-eps)
					{fl=0; break;}
				tmx=max(tmx,a[i].l*c+a[i].p);
			}
			if (!fl) break;
			mx=max(mx,tmx);
		}
		if (fl) l=c; else r=c;
	}
	printf("%.10Lf\n",l);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB long double
const DB eps=0.000000000001;
int n,fl; LL T,tt,t;
DB l,r,mx,tmx,c;
struct O{
	LL p,t; DB l,r;
}a[150005];
bool cmp(O a,O b){
	return a.p*b.t==b.p*a.t?a.p<b.p:a.p*b.t>b.p*a.t;
}
bool cms(O a,O b){
	return a.p<b.p;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%lld",&a[i].p);
	for (int i=1;i<=n;++i) scanf("%lld",&a[i].t),T+=a[i].t;
	sort(a+1,a+n+1,cmp);
	for (int i=1,j;i<=n;i=j){
		tt=0;
		for (j=i;j<=n&&a[j].p*a[i].t==a[i].p*a[j].t;++j)
			tt+=a[j].t,a[j].l=-(DB)(t+a[j].t)*a[j].p/T;
		t+=tt;
		for (j=i;j<=n&&a[j].p*a[i].t==a[i].p*a[j].t;++j)
			a[j].r=-(DB)t*a[j].p/T;
	}
	sort(a+1,a+n+1,cms);
	l=0; r=1;
	while (r-l>0.00000000001){
		mx=0; c=(l+r)/2; fl=1;
		for (int i=1,j;i<=n;i=j){
			tmx=0;
			for (j=i;j<=n&&a[j].p==a[i].p;++j){
				if (a[j].r*c+a[j].p<mx-eps)
					{fl=0; break;}
				tmx=max(tmx,a[j].l*c+a[j].p);
			}
			if (!fl) break;
			mx=max(mx,tmx);
		}
		if (fl) l=c; else r=c;
	}
	printf("%.9Lf\n",l);
	return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 15e4 + 10, INF = 1e9;

int p[N], t[N], ord[N], n, per[N];
ll sum = 0;
ld lf[N], rg[N];

bool cmp(int i, int j){
	pair<ll, ll> res1 = {1LL * t[i] * p[j], p[i]};
	pair<ll, ll> res2 = {1LL * t[j] * p[i], p[j]};
	return res1 < res2;
}

bool pmc(int i, int j){
	return p[i] < p[j];
}

bool check(ld c){
	ll tim = 0;
	int i = 0, j = 0;
	while(i < n){
		ll foo = 0;
		while(j < n && 1LL * t[ord[i]] * p[ord[j]] == 1LL * t[ord[j]] * p[ord[i]]){
			foo += t[ord[j]];
			j++;
		}
		for(int k=i; k<j; k++){
			lf[ord[k]] = p[ord[k]] * (1.0 - c * (tim + t[ord[k]])/sum);
			rg[ord[k]] = p[ord[k]] * (1.0 - c * (tim + foo)/sum);
		}
		i = j;
		tim += foo;
	}

	for(int i=0; i<n; i++)
		swap(lf[i], rg[i]);

	i = n - 1, j = n - 1;
	ld mn = INF;
	while(i >= 0){
		ld foo = INF, oof = -1;
		while(j>=0 && p[per[i]] == p[per[j]]){
			foo = min(foo, lf[per[j]]);
			oof = max(oof, rg[per[j]]);
			j--;
		}
		if(oof > mn)return false;
		mn = min(mn, foo);
		i = j;
	}
	return true;
}

int main(){

	cin >> n;
	for(int i=0; i<n; i++)
		cin >> p[i];
	for(int i=0; i<n; i++){
		cin >> t[i]; sum += t[i];
	}

	for(int i=0; i<n; i++)
		ord[i] = i, per[i] = i;

	sort(ord, ord + n, cmp);
	sort(per, per + n, pmc);

	ld lo = 0, hi = 1;
	for(int i=0; i<50; i++){
		ld mid = (lo + hi)/2;
		if(check(mid))lo = mid;
		else hi = mid;
	}
	cout << fixed << setprecision(11) << lo << endl;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> Piii;
int N;
ll T;
Pii ps[150000];
ll tmn[150001],tmx[150001];
bool same(Pii &l,Pii &r){
	return l.fs*r.sc-l.sc*r.fs==0;
}
bool comp(Pii &l,Pii &r){
	return l.fs*r.sc-l.sc*r.fs>0;
}
bool comp2(Piii &l,Piii &r){
	return l.fs.sc<r.fs.sc;
}
int o[150000];
Piii x[150000];
void getorder(){
	rep(i,N) x[i]=Piii(ps[i],i);
	sort(x,x+N,comp2);
	rep(i,N) o[i]=x[i].sc;
}
double maxscore(int i,double c){
	return ps[i].fs*(1-c*tmn[i]/T);
}
double minscore(int i,double c){
	return ps[i].fs*(1-c*tmx[i]/T);
}
bool can(double c){
	double mx=0;
	int pre=0;
	rep(i,N){
//		show(i);
//		show(o[i]);
		if(ps[o[pre]].sc<ps[o[i]].sc){
			for(int j=pre;j<i;j++) chmax(mx,maxscore(o[j],c));
			pre=i;
		}
//		show(mx);
		if(mx>minscore(o[i],c)){
//			show(minscore(o[i],c));
			return 0;
		}
	}
	return 1;
}
int main(){
	cin>>N;
	rep(i,N) cin>>ps[i].fs;
	rep(i,N) cin>>ps[i].sc;
	sort(ps,ps+N,comp);
	ll tsum=0;
	int pre=0;
	rep(i,N+1){
//		show(i);
//		show(tsum);
		if(i<N&&same(ps[pre],ps[i])) tmn[i]=tmn[pre];
		else{
//			show(pre);
//			show(tsum);
			for(int j=pre;j<i;j++) tmx[j]=tsum;
			if(i==N) break;
			tmn[i]=tsum;
			pre=i;
		}
		tsum+=ps[i].sc;
	}
	T=tsum;
	rep(i,N) tmn[i]+=ps[i].sc;
	getorder();
//	rep(i,N) show(tmn[i]),show(tmx[i]);
	double ub=1,lb=0;
	rep(tt,30){
		double m=(ub+lb)/2;
		if(can(m)) lb=m;
		else ub=m;
	}
	printf("%.12f\n",ub);
//	show(can(0.5));
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> Piii;
int N;
ll T;
Pii ps[150000];
ll tmn[150001],tmx[150001];
bool same(Pii &l,Pii &r){
	return l.fs*r.sc-l.sc*r.fs==0;
}
bool comp(Pii &l,Pii &r){
	return l.fs*r.sc-l.sc*r.fs>0;
}
bool comp2(Piii &l,Piii &r){
	return l.fs.sc<r.fs.sc;
}
int o[150000];
Piii x[150000];
void getorder(){
	rep(i,N) x[i]=Piii(ps[i],i);
	sort(x,x+N,comp2);
	rep(i,N) o[i]=x[i].sc;
}
double maxscore(int i,double c){
	return ps[i].fs*(1-c*tmn[i]/T);
}
double minscore(int i,double c){
	return ps[i].fs*(1-c*tmx[i]/T);
}
bool can(double c){
	double mx=0;
	int pre=0;
	rep(i,N){
		if(ps[o[pre]].sc<ps[o[i]].sc){
			for(int j=pre;j<i;j++) chmax(mx,maxscore(o[j],c));
			pre=i;
		}
		if(mx>minscore(o[i],c)) return 0;
	}
	return 1;
}
int main(){
	cin>>N;
	rep(i,N) cin>>ps[i].fs;
	rep(i,N) cin>>ps[i].sc;
	sort(ps,ps+N,comp);
	ll tsum=0;
	int pre=0;
	rep(i,N+1){
		if(i<N&&same(ps[pre],ps[i])) tmn[i]=tmn[pre];
		else{
			for(int j=pre;j<i;j++) tmx[j]=tsum;
			if(i==N) break;
			tmn[i]=tsum;
		}
		tsum+=ps[i].sc;
	}
	T=tsum;
	rep(i,N) tmn[i]+=ps[i].sc;
	getorder();
	double ub=1,lb=0;
	rep(tt,30){
		double m=(ub+lb)/2;
		if(can(m)) lb=m;
		else ub=m;
	}
	printf("%.12f\n",ub);
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> Piii;
int N;
ll T;
Pii ps[150000];
ll tmn[150001],tmx[150001];
bool same(Pii &l,Pii &r){
	return l.fs*r.sc-l.sc*r.fs==0;
}
bool comp(Pii &l,Pii &r){
	return l.fs*r.sc-l.sc*r.fs>0;
}
bool comp2(Piii &l,Piii &r){
	return l.fs.fs<r.fs.fs;
}
int o[150000];
Piii x[150000];
void getorder(){
	rep(i,N) x[i]=Piii(ps[i],i);
	sort(x,x+N,comp2);
	rep(i,N) o[i]=x[i].sc;
}
double maxscore(int i,double c){
	return ps[i].fs*(1-c*tmn[i]/T);
}
double minscore(int i,double c){
	return ps[i].fs*(1-c*tmx[i]/T);
}
bool can(double c){
	double mx=0;
	int pre=0;
	rep(i,N){
//		show(i);
//		show(o[i]);
		if(ps[o[pre]].fs<ps[o[i]].fs){
			for(int j=pre;j<i;j++) chmax(mx,maxscore(o[j],c));
			pre=i;
		}
//		show(mx);
		if(mx>minscore(o[i],c)){
//			show(minscore(o[i],c));
			return 0;
		}
	}
	return 1;
}
int main(){
	cin>>N;
	rep(i,N) cin>>ps[i].fs;
	rep(i,N) cin>>ps[i].sc;
	sort(ps,ps+N,comp);
	ll tsum=0;
	int pre=0;
	rep(i,N+1){
//		show(i);
//		show(tsum);
		if(i<N&&same(ps[pre],ps[i])) tmn[i]=tmn[pre];
		else{
//			show(pre);
//			show(tsum);
			for(int j=pre;j<i;j++) tmx[j]=tsum;
			if(i==N) break;
			tmn[i]=tsum;
			pre=i;
		}
		tsum+=ps[i].sc;
	}
	T=tsum;
	rep(i,N) tmn[i]+=ps[i].sc;
	getorder();
//	rep(i,N) show(tmn[i]),show(tmx[i]);
	double ub=1,lb=0;
	rep(tt,30){
		double m=(ub+lb)/2;
		if(can(m)) lb=m;
		else ub=m;
	}
	printf("%.12f\n",ub);
//	show(can(0.5));
}


#include <algorithm>
#include <cstdio>
#include <utility>
#include <map>
#include <vector>

#define MAXN 200000

using namespace std;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;

int n;
pii a[MAXN];
long long s[MAXN];
long long T;

vector <vector <int>> groups;
pll range[MAXN];

map <int, vector <int>> order;

bool check(double c) {
    double last = -1;
    for (auto& kv : order) {
        double minval = 1e30, maxval = 0;
        for (int i : kv.second) {
            minval = min(minval, 1.0 * kv.first * (T - c * range[i].second));
            maxval = max(maxval, 1.0 * kv.first * (T - c * range[i].first));
        }
        if (minval < last)
            return false;
        last = maxval;
    }
    return true;
}

bool cmp(const pii& x, const pii& y) {
    long long xval = 1LL * x.first * y.second;
    long long yval = 1LL * y.first * x.second;
    if (xval > yval)
        return true;
    if (xval < yval)
        return false;
    return x.first < y.first;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i].first);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i].second);

    sort(a, a + n, cmp);
    for (int i = 0; i < n; i++) {
        s[i + 1] = s[i] + a[i].second;
        T += a[i].second;
    }

    // group by p_i / t_i
    pii last{a[0]};
    vector <int> g;
    for (int i = 0; i < n; i++) {
        if (1LL * last.first * a[i].second != 1LL * a[i].first * last.second) {
            last = a[i];
            groups.push_back(g);
            g.clear();
        }
        g.push_back(i);
    }
    groups.push_back(g);

    // calculate ranges
    for (auto& g : groups)
        for (int i : g)
            range[i] = {s[g[0]] + a[i].second, s[g.back() + 1]};

    // group by p_i
    for (int i = 0; i < n; i++)
        order[a[i].first].push_back(i);

    double low = 0, high = 1;
    for (int l = 0; l < 30; l++) {
        double mid = 0.5 * (low + high);
        if (check(mid))
            low = mid;
        else
            high = mid;
    }
    printf("%.10f\n", low);
}


#include <algorithm>
#include <cstdio>
#include <utility>
#include <map>
#include <vector>

#define MAXN 200000

using namespace std;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;

int n;
pii a[MAXN];
long long s[MAXN];
long long T;

vector <vector <int>> groups;
pll range[MAXN];

map <int, vector <int>> order;

bool check(double c) {
    double last = -1;
    for (auto& kv : order) {
        double minval = 1e30, maxval = 0;
        for (int i : kv.second) {
            minval = min(minval, 1.0 * kv.first * (T - c * range[i].second));
            maxval = max(maxval, 1.0 * kv.first * (T - c * range[i].first));
        }
        if (minval < last)
            return false;
        last = maxval;
    }
    return true;
}

bool cmp(const pii& x, const pii& y) {
    long long xval = 1LL * x.first * y.second;
    long long yval = 1LL * y.first * x.second;
    if (xval > yval)
        return true;
    if (xval < yval)
        return false;
    return x.first < y.first;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i].first);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i].second);

    sort(a, a + n, cmp);
    for (int i = 0; i < n; i++) {
        s[i + 1] = s[i] + a[i].second;
        T += a[i].second;
    }

    // group by p_i / t_i
    pii last{a[0]};
    vector <int> g;
    for (int i = 0; i < n; i++) {
        if (1LL * last.first * a[i].second != 1LL * a[i].first * last.second) {
            last = a[i];
            groups.push_back(g);
            g.clear();
        }
        g.push_back(i);
    }
    groups.push_back(g);

    // calculate ranges
    for (auto& g : groups)
        for (int i : g)
            range[i] = {s[g[0]] + a[i].second, s[g.back() + 1]};

    // group by p_i
    for (int i = 0; i < n; i++)
        order[a[i].first].push_back(i);

    double low = 0, high = 1;
    for (int l = 0; l < 100; l++) {
        double mid = 0.5 * (low + high);
        if (check(mid))
            low = mid;
        else
            high = mid;
    }
    printf("%.10f\n", low);
}