#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef std::string str;
#define sei set<int>
#define sell set<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vld vector<ld>
#define vstr vector<str>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(v) v.begin(),v.end()
#define foa(i,v) for(auto i : v)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define deb(x)  cerr << #x << " = " << x << endl
#define pb push_back
#define pob pop_back
#define F first
#define S second
#define OK order_of_key
#define FO find_by_order
#define nmax 51
const ld PI = 3.141592653589793238462643383279;
const ll inf = std::numeric_limits<ll>::max();
const int infint = std::numeric_limits<int>::max();
const ll mod = 1e9+7;
using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll dp[nmax][nmax];
pll a[nmax];
int n;

bool check(ll k){
    fo(i,0,nmax) fo(j,0,nmax) dp[i][j] = -4e18;
    dp[0][0] = a[0].S*k-a[0].F;
    fo(i,1,n) fo(j,0,i+1){
        if(j == 0){
            dp[i][j] = dp[i-1][j] + a[i].S*k-a[i].F;
        }else{
            if(a[i].F != a[j].F) dp[i][j] = max(dp[i-1][j] + a[i].S*k-a[i].F,dp[i-1][j-1] + a[i].S*k-a[i].F - (a[j-1].S*k-a[j-1].F));
            else dp[i][j] = dp[i-1][j] + a[i].S*k-a[i].F;
        }
    }

    ll mx = -1;
    fo(i,0,n) mx = max(mx,dp[n-1][i]);
    //cout << k << ' ' << mx << endl;
    //if(k == 1000) fo(i,0,n) cout << dp[n-1][i] << endl;
    return mx>=0;
}

ll bis(ll l,ll r){
    if(l == r) return l;
    ll mid = (l+r)/2;
    if(check(mid)) return bis(l,mid);
    else return bis(mid+1,r);
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin >> n;
    fo(i,0,n) cin >> a[i].F,a[i].F *= 1000;
    fo(i,0,n) cin >> a[i].S;
    sort(a,a+n);
    cout << bis(1,5e9);


    return 0;
}

