#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#define int long long
using namespace std;
const int MXN=120;
struct rec{
	int a,b;
}t[MXN];
int n;
inline int read(){
	int X=0,z=0;char ch=0;
	while(!isdigit(ch)) z=ch=='-'?1:0,ch=getchar();
	while(isdigit(ch)) X=(X<<1)+(X<<3)+(ch^48),ch=getchar(); 
	return z?-X:X;
}
double c[MXN];
int lim;
bool cmp(double x,double y){
	return x>y;
}
double f[56][56][56];
double mymin(double x,double y){
	return x<y?x:y;
}
inline double dp(){
	memset(f,0x7f,sizeof(f));
	f[0][0][0]=0;
	f[1][0][1]=c[1];
	for(int i=2;i<=n;++i){
		for(int j=0;j<=n;++j){
			for(int k=0;k<=n;++k){
				if(t[i].a==t[i-1].a){
					if(j+1<=i-1) f[i][j][k]=mymin(f[i][j][k],f[i-1][j+1][k]);
					if(k-1>=0&&j<=i) f[i][j][k]=mymin(f[i-1][j][k-1]+c[i],f[i][j][k]);
				}
				if(j+k-1>=0) f[i+1][j+k-1][0]=mymin(f[i][j][k],f[i+1][j+k-1][0]);
                f[i+1][j+k][1]=mymin(f[i][j][k]+c[i+1],f[i+1][j+k][1]);
		    }
	    }
	}
	double ret=188888888.0;
	for(int j=0;j<=n;++j){
		for(int k=0;k<=n;++k){
			ret=mymin(ret,f[n][j][k]);
		}
	}
	return ret;
}
bool Examine(double x){
	for(register int i=1;i<=n;++i)
		c[i]=((double)t[i].a)-x*((double)t[i].b) ;
    return dp()<=0;
}
inline int Binary_Search(){
	double L=-3.0,R=1e11,mid;
	while((R-L)>(1e-9)){
		mid=L+(R-L)/2;
		if(Examine(mid)) R=mid;
		else L=mid;
	}
	return (int)(R*1000);
}
bool cmprec(rec x,rec y){
	return x.a>y.a;
}
main(){
 	n=read();
 	for(int i=1;i<=n;++i) t[i].a=read();
 	for(int i=1;i<=n;++i) t[i].b=read();
 	sort(t+1,t+1+n,cmprec);
 	printf("%lld",Binary_Search());
	return 0;
}