#include <bits/stdc++.h>
using namespace std;
const long double INF = 1e16;
const long double eps = 1e-9;
long long a[105];
long long b[105];
int n;
long double dp[105][105];
int gr = 0;
long double val = 0;
bool cmp(int i, int j) {
  return (((long double)b[i] * val - a[i]) + eps <
          ((long double)b[j] * val - a[j]));
}
long double pref[150];
bool ok(long double x) {
  val = x;
  for (int i = 0; i <= gr; i++) {
    for (int j = 0; j <= n; j++) {
      dp[i][j] = -INF;
    }
  }
  dp[0][0] = 0;
  int l = 1;
  int r = 1;
  for (int i = 0; i < gr; i++) {
    r = l;
    while (a[r] == a[l]) r++;
    r--;
    vector<int> t;
    for (int j = l; j <= r; j++) t.push_back(j);
    sort(t.begin(), t.end(), cmp);
    reverse(t.begin(), t.end());
    pref[0] = 0.0;
    for (int i = 0; i < t.size(); i++) {
      pref[i + 1] = pref[i] + ((long double)b[t[i]] * x - a[t[i]]);
    }
    for (int open = 0; open <= n; open++) {
      for (int cnt = 0; cnt <= r - l + 1; cnt++) {
        if (open < cnt) continue;
        dp[i + 1][open - cnt + (r - l + 1) - cnt] =
            max(dp[i + 1][open - cnt + (r - l + 1) - cnt],
                dp[i][open] + pref[(r - l + 1) - cnt]);
      }
    }
    l = r + 1;
  }
  for (int i = 0; i <= n; i++) {
    if (dp[gr][i] >= -eps) return true;
  }
  return false;
}
set<long long> s;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] *= 1000;
    s.insert(a[i]);
  }
  for (int j = 1; j <= n; j++) {
    cin >> b[j];
  }
  gr = s.size();
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (a[i] < a[j]) {
        swap(a[i], a[j]);
        swap(b[i], b[j]);
      }
    }
  }
  long double l = 0;
  long double r = 1e10;
  for (int iter = 0; iter < 10000; iter++) {
    if ((r - l) < eps) break;
    long double mid = (l + r) / 2;
    if (ok(mid))
      r = mid;
    else
      l = mid;
  }
  cout << (long long)(r + 0.5 + eps);
  return 0;
}
