#include <bits/stdc++.h>
using namespace std;
const int N = 55;
const long long INF = 4e18;
const long long MX = 1e12;
int n;
long long a[N][2];
pair<long long, long long> b[N];
long long f[N][N];
bool check(long long mid) {
  for (int i = 0; i < n; ++i) {
    b[i] = make_pair(a[i][0], a[i][0] - mid * a[i][1]);
  }
  sort(b, b + n), reverse(b, b + n);
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      f[i][j] = INF;
    }
  }
  f[0][0] = 0;
  int l = 0;
  while (l < n) {
    int r = l;
    while (r < n && b[r].first == b[l].first) r++;
    for (int was = 0; was <= l; ++was)
      if (f[l][was] != INF) {
        long long sum = f[l][was];
        for (int i = l; i < r; ++i) sum += b[i].second;
        for (int cnt = 0; cnt <= r - l; ++cnt) {
          if (cnt <= was)
            f[r][was - cnt + r - l - cnt] =
                min(f[r][was - cnt + r - l - cnt], sum);
          sum -= b[l + cnt].second;
        }
      }
    l = r;
  }
  for (int i = 0; i <= n; ++i)
    if (f[n][i] <= 0) {
      return true;
    }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a[j][i];
    }
  }
  for (int i = 0; i < n; ++i) a[i][0] *= 1000;
  long long l = 0, r = MX;
  while (l < r) {
    long long mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << l << '\n';
}
