#include <bits/stdc++.h>
using namespace std;
const int mxN = 50;
const long long INF = 1e18;
int n;
pair<long long, long long> ps[mxN + 1];
long long dp[mxN + 1][mxN + 1];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> ps[i].first;
  for (int i = 0; i < n; ++i) cin >> ps[i].second;
  sort(ps, ps + n, greater<pair<long long, long long> >());
  long long lb = 1, rb = 1e12;
  while (lb <= rb) {
    long long mb = (lb + rb) / 2;
    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) dp[0][i] = INF;
    for (int i = 1; i <= n; ++i) {
      int k = i;
      while (k < n && ps[k].first == ps[k - 1].first) ++k;
      long long cs = 0;
      for (int j = 0; j <= n; ++j) dp[k][j] = INF;
      for (int l = 0; l <= k - i + 1; ++l) {
        for (int j = l; j + (k - i + 1) - 2 * l <= n && j <= n; ++j)
          dp[k][j] = min(dp[i - 1][j + (k - i + 1) - 2 * l] + cs, dp[k][j]);
        cs += 1000 * ps[i - 1 + l].first - mb * ps[i - 1 + l].second;
      }
      i = k;
    }
    bool ok = 0;
    for (int i = 0; i <= n && !ok; ++i) ok = dp[n][i] <= 0;
    if (ok)
      rb = mb - 1;
    else
      lb = mb + 1;
  }
  cout << lb;
}
