#include <bits/stdc++.h>
using namespace std;
const long long int big = 2.19e15 + 1;
const long double pai = 3.141592653589793238462643383279502884197;
const long double eps = 1e-15;
template <class T, class U>
void mineq(T& a, U b) {
  if (a > b) {
    a = b;
  }
}
template <class T, class U>
void maxeq(T& a, U b) {
  if (a < b) {
    a = b;
  }
}
long long int gcd(long long int a, long long int b) {
  if (a % b == 0) {
    return b;
  } else
    return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
template <class T>
void SO(T& ve) {
  sort(ve.begin(), ve.end());
}
template <class T>
void REV(T& ve) {
  reverse(ve.begin(), ve.end());
}
template <class T>
long long int LBI(vector<T>& ar, T in) {
  return lower_bound(ar.begin(), ar.end(), in) - ar.begin();
}
template <class T>
long long int UBI(vector<T>& ar, T in) {
  return upper_bound(ar.begin(), ar.end(), in) - ar.begin();
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long int n, h, i, j, bmax = 1.01e11, bmin = 0;
  cin >> n;
  vector<pair<long long int, int>> tas(n);
  for (i = 0; i < n; i++) {
    cin >> tas[i].first;
    tas[i].first *= 1000;
  }
  for (i = 0; i < n; i++) {
    cin >> tas[i].second;
  }
  SO(tas);
  REV(tas);
  tas.push_back(make_pair(-big, 0));
  while (bmax - bmin > 1) {
    long long int bgen = (bmax + bmin) / 2;
    array<long long int, 51> dp = {0};
    for (i = 1; i <= 50; i++) {
      dp[i] = big;
    }
    long long int mae = big;
    int ren = 0;
    vector<long long int> hyo;
    hyo.push_back(0);
    for (h = 0; h <= n; h++) {
      long long int pw = tas[h].first;
      int coa = tas[h].second;
      if (pw != mae) {
        array<long long int, 51> ddp;
        for (i = 0; i <= 50; i++) {
          ddp[i] = big;
        }
        int hs = hyo.size() - 1;
        for (j = 0; j <= hs; j++) {
          for (i = max(0LL, hs - j); i <= 50 && i - hs + j + j <= 50; i++) {
            mineq(ddp[i - hs + j + j], dp[i] + hyo[j]);
          }
        }
        dp = ddp;
        hyo.clear();
        hyo.push_back(0);
        mae = pw;
      }
      long long int futa = pw - bgen * coa;
      vector<long long int> nh(hyo.size() + 1, big);
      for (i = 0; i < hyo.size(); i++) {
        mineq(nh[i], hyo[i]);
        mineq(nh[i + 1], hyo[i] + futa);
      }
      hyo = nh;
    }
    for (i = 50; i > 0; i--) {
      mineq(dp[i - 1], dp[i]);
    }
    if (dp[0] <= 0) {
      bmax = bgen;
    } else {
      bmin = bgen;
    }
  }
  cout << bmax << endl;
  return 0;
}
