#include <bits/stdc++.h>
using namespace std;
long long INF = 1e16;
int n;
vector<long long> a, b;
bool can(long long tr) {
  vector<long long> c(n);
  for (int i = 0; i < n; i++) {
    c[i] = a[i] - b[i] * tr;
  }
  vector<pair<long long, long long>> cc(n);
  for (int i = 0; i < n; i++) cc[i] = {a[i], -c[i]};
  sort(cc.rbegin(), cc.rend());
  for (int i = 0; i < n; i++) {
    c[i] = -cc[i].second;
  }
  vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, INF));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    long long cur = 0;
    int j = i;
    while (j < n && cc[i].first == cc[j].first) cur += c[j], j++;
    long long fcur = cur;
    int cnt = j - i;
    for (int bal = 0; bal <= i; bal++) {
      cur = fcur;
      for (int close = 0; close <= min(cnt, bal); close++) {
        if (close > 0) cur -= c[j - close];
        int nbal = bal - close + (cnt - close);
        if (nbal >= 0) {
          dp[j][nbal] = min(dp[j][nbal], dp[i][bal] + cur);
        }
      }
    }
  }
  for (int i = 0; i <= n; i++) {
    if (dp[n][i] <= 0) return 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(30);
  cin >> n;
  a.assign(n, 0), b.assign(n, 0);
  for (long long &i : a) cin >> i, i *= 1000;
  for (long long &i : b) cin >> i;
  long long l = 0, r = 1e16;
  while (r - l > 1) {
    long long m = (l + r) / 2;
    if (can(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  cout << r << endl;
  return 0;
}
