#include <bits/stdc++.h>
using namespace std;
long double dp[52][52][52];
struct task {
  long double a, b;
  long double val;
};
int n;
vector<task> v;
long double ok(long double x) {
  for (int i = 1; i <= n; ++i) {
    v[i].val = x * v[i].b - v[i].a;
  }
  for (int i = 0; i <= n + 1; ++i)
    for (int j = 0; j <= n + 1; ++j)
      for (int k = 0; k <= n + 1; ++k) {
        dp[i][j][k] = -(1LL << 40);
      }
  dp[0][0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < i; j++) {
      if (v[i - 1].a == v[i].a) {
        for (int k = 0; (j + k) <= i; ++k) {
          if (k) dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][k - 1] + v[i].val);
          dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j + 1][k]);
        }
      } else {
        for (int k = 0; k <= j; k++) {
          dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j - k][k] + v[i].val);
        }
        for (int k = 0; k <= j; ++k) {
          dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j - k][k + 1]);
          dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j - k + 1][k]);
        }
      }
    }
  }
  long double sol = -(1LL << 30);
  for (int j = 0; j <= n; ++j) {
    for (int k = 0; k <= n; ++k) {
      sol = max(sol, dp[n][j][k]);
    }
  }
  return 0 < sol;
}
const long double EPS = 1e-10;
long double binsrc() {
  long double st = 0, dr = 200000000, sol = dr;
  while (dr - st > EPS) {
    long double mid = (st + dr) / 2;
    if (ok(mid)) {
      sol = mid;
      dr = mid;
    } else {
      st = mid;
    }
  }
  return sol;
}
bool cmp(task a, task b) { return a.a > b.a; }
int main() {
  cin >> n;
  v.resize(n + 1);
  for (long double i = 1; i <= n; ++i) {
    cin >> v[i].a;
  }
  for (long double i = 1; i <= n; ++i) {
    cin >> v[i].b;
  }
  sort(v.begin() + 1, v.end(), cmp);
  long double sol = binsrc();
  cout << (long long)ceil((sol - EPS * 1000) * 1000) << "\n";
  return 0;
}
