#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
long long dp[55][55][5005];
map<int, int> mp;
int cnt;
int a[55], b[55];
vector<pair<int, int> > ls[55];
void fmain(int ID) {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d", a + i);
    mp[a[i]];
  }
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%d", b + i);
  for (auto& p : mp) p.second = ++cnt;
  for (int(i) = 1; (i) <= (int)(n); (i)++) ls[mp[a[i]]].push_back({-b[i], i});
  for (int(i) = 0; (i) < (int)(55); (i)++)
    for (int(j) = 0; (j) < (int)(55); (j)++)
      for (int(z) = 0; (z) < (int)(5005); (z)++) dp[i][j][z] = (1LL << 60);
  dp[0][0][0] = 0;
  for (int(i) = 1; (i) <= (int)(cnt); (i)++) {
    int tar = cnt + 1 - i;
    int N = ls[tar].size();
    sort(ls[tar].begin(), ls[tar].end());
    long long sb = 0, sa = 0;
    for (int to1 = 0; to1 <= N; to1++) {
      for (int c = N - to1; c <= 50; c++) {
        for (int z = 0; z < 5005; z++)
          if (dp[i - 1][c][z] < (1LL << 60)) {
            mintt(dp[i][c - (N - to1) + to1][z + sb], dp[i - 1][c][z] + sa);
          }
      }
      if (to1 == N) break;
      sb -= ls[tar][to1].first;
      sa += a[ls[tar][to1].second];
    }
  }
  long long ans = (1LL << 60);
  for (int c = 0; c <= 50; c++) {
    for (int z = 1; z < 5005; z++)
      if (dp[cnt][c][z] < (1LL << 60)) {
        long long A = dp[cnt][c][z] * 1000;
        long long tt = A / z;
        if (A % z != 0) tt++;
        mintt(ans, tt);
      }
  }
  printf("%lld\n", ans);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
