#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) > (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define x first
#define y second
#define pb push_back
#define PB pop_back()
#define iOS ios_base::sync_with_stdio(false)
#define sqr(a) (((a) * (a)))
#define all(a) a.begin() , a.end()
#define error(x) cerr << #x << " = " << (x) <<endl
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define errop(a) cerr<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define L(x) ((x)<<1)
#define R(x) (((x)<<1)+1)
#define umap unordered_map
#define double long double
typedef long long ll;
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef complex<double> point;
template <typename T> using os =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}
const int maxn = 60;
double inf = 1e22, thr = 1e20, eps = 1e-6;
pii p[maxn];
double dp[maxn][maxn];
int n, m;
set<int> se;
inline bool check(double x){
	fill(&dp[0][0], &dp[0][0] + maxn * maxn, -inf);
	dp[0][0] = 0;
	int cur = 0;
	For(i,0,n){
		++ cur;
		int k = i, t;
		while(k + 1 < n && p[i].x == p[k+1].x)
			++ k;
		t = k - i + 1;
		For(j,0,i+1){
			if(dp[cur-1][j] < -thr)	continue ;
			double d = 0;
			int h = t, e=0;
			For(r, i, k + 1){
				double tt = -p[r].x + p[r].y * x;
				d += tt;
				-- h;
				++ e;
				if(j >= h)
					smax(dp[cur][j-h+e], dp[cur-1][j] + d);
			}
			if(j >= t)
				smax(dp[cur][j-t], dp[cur-1][j]);
		}
		i = k;
	}
	For(i,0,n+1)
		if(dp[m][i] >= -eps){
			return true;
		}
	return false;

}
int main(){
	iOS;
	cin >> n;
	For(i,0,n){
		cin >> p[i].x;
		se.insert(p[i].x);
	}
	m = se.size();
	For(i,0,n)
		cin >> p[i].y;
	sort(p, p + n, [](const pii &i, const pii &j){if(i.x != j.x)	return i.x > j.x; return i.y > j.y;});
	double lo = 0, hi = 1e8 + 100;
	int cur = 0;
	while(hi - lo > eps){
		double mid = (lo + hi) / 2.;
		if(check(mid)){
			hi = mid;
		}
		else
			lo = mid;
		cur ++;
	}
	cout << (int)ceil(lo * 1000) << endl;
	return 0;
}

