#include <bits/stdc++.h>
using namespace std;
const int N = 2e2 + 1;
const long long INF = 1e18 + 9;
const int B = 1e9 + 7;
long long n;
pair<long long, long long> a[N];
long long d[N][N];
long long getmin(long long x) {
  for (int i = int(1); i <= int(n); ++i) d[0][i] = INF;
  int prv = 0;
  for (int i = int(1); i <= int(n); ++i) {
    if (a[i - 1].first != a[i].first) prv = i - 1;
    for (int j = int(0); j <= int(n); ++j) {
      d[i][j] = j + (i - prv) <= n ? d[prv][j + (i - prv)] : INF;
      if (j > 0)
        d[i][j] =
            min(d[i][j], d[i - 1][j - 1] + (a[i].first - x * a[i].second));
    }
  }
  long long ans = INF;
  for (int i = int(0); i <= int(n); ++i) ans = min(ans, d[n][i]);
  return ans;
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = int(1); i <= int(n); ++i) cin >> a[i].first;
  for (int i = int(1); i <= int(n); ++i) cin >> a[i].second;
  sort(a + 1, a + 1 + n, greater<pair<long long, long long> >());
  for (int i = int(1); i <= int(n); ++i) a[i].first *= 1000;
  long long l = 1, r = 1e12;
  while (l < r) {
    long long x = (l + r + 1) / 2;
    if (getmin(x) >= 0)
      l = x;
    else
      r = x - 1;
  }
  cout << l << "\n";
  return 0;
}
