#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define LOG 19
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less< i64 >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 200005

i64 dp[52][52][5005] ;
pair<int,int> a[55] ;
pair<i64,i64> b[55] ;

int main()
{
    int n ;
    scanf("%d",&n) ;
    for(int i=1 ; i<=n ; i++) scanf("%d",&a[i].xx) ;
    for(int i=1 ; i<=n ; i++) scanf("%d",&a[i].yy) ;

    sort(a+1,a+n+1) ;
    reverse(a+1,a+n+1) ;

    for(int i=1; i<=n ; i++)
    {
        b[i].xx = b[i-1].xx + a[i].xx ; b[i].yy = b[i-1].yy + a[i].yy ;
    }

    for(int i=0 ; i<=n ; i++)
    {
        for(int j=0 ; j<=n ; j++)
        {
            for(int k=0 ; k<=n*100 ; k++) dp[i][j][k] = INF ;
        }
    }

    dp[0][0][0] = 0 ;

    for(int i=1; i<=n ; i++)
    {
        int l = i-1 , r = i ;
        while( r+1 <=n && a[r+1].xx == a[r].xx ) r++ ;

        for(int bal=0 ; bal<=l ; bal++)
        {
            for(int pro=0 ; pro<=l*100 ; pro++)
            {
                if( dp[l][bal][pro] == INF ) continue ;

                for(int j=0 ; j<=bal && j<=r-l ; j++)
                {
                    dp[r][ bal-j+(r-l)-j ][ b[r].yy-b[l+j].yy+pro ] = min( dp[r][ bal-j+(r-l)-j ][ b[r].yy-b[l+j].yy+pro ] , dp[l][bal][pro]+b[r].xx-b[l+j].xx  ) ;
                }
            }
        }
        i = r ;
 /*       printf("%d\n",r) ;
        for(int bal = 0 ; bal<=r ; bal++)
        {
            for(int pro=0 ; pro<=r*100 ; pro++)
            {
                if(dp[r][bal][pro]==INF) continue ;
                printf("%d %d %d: %lld\n",r,bal,pro,dp[r][bal][pro]) ;
            }
        } */
    }

    i64 ans = INF ;

    for(int pro = 0 ; pro<=n*100 ; pro++)
    {
        for(int i=0 ; i<=n ; i++)
        {
            dp[n][n][pro] = min( dp[n][n][pro] , dp[n][i][pro] ) ;
        }
        if( dp[n][n][pro] == INF ) continue ;
   //     printf("%d %lld\n" , pro , dp[n][n][pro] ) ;
        ans = min( ans , (dp[n][n][pro]*1000+pro-1)/pro ) ;
    }

    printf("%lld\n",ans) ;

    return 0 ;
}
