#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> A[55];
double pos[55][55];
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first > b.first)
    return 1;
  else if (a.first < b.first)
    return 0;
  else {
    return a.second <= b.second;
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> A[i].first;
  for (int i = 1; i <= n; ++i) cin >> A[i].second;
  sort(A + 1, A + n + 1, comp);
  double low = 0;
  double high = 1e100;
  int count = 10000;
  while (count--) {
    double mid = low + high;
    mid /= 2.0;
    for (int i = 0; i <= n; ++i) {
      for (int j = 0; j <= n; ++j) {
        pos[i][j] = 1e100;
      }
    }
    pos[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
      long long st = A[i].first;
      int u = i - 1;
      while (i <= n && A[i].first == st) ++i;
      --i;
      int coun = i - u;
      double sum[55];
      for (int j = u + 1; j <= i; ++j) sum[j - u] = 0;
      sum[0] = 0;
      for (int j = u + 1; j <= i; ++j)
        sum[j - u] = sum[j - u - 1] + A[j].second;
      double sum2[55];
      for (int j = u + 1; j <= i; ++j) sum2[j - u] = 0;
      sum2[0] = 0;
      for (int j = u + 1; j <= i; ++j)
        sum2[j - u] = sum2[j - u - 1] + A[j].first;
      for (int j = 0; j <= u; ++j) {
        for (int l = 0; l <= min(coun, j); ++l) {
          int rem = j - l + coun - l;
          pos[i][rem] =
              min(pos[i][rem], pos[u][j] - (sum[coun] - sum[l]) * mid +
                                   (sum2[coun] - sum2[l]));
        }
      }
    }
    bool flag = 0;
    for (int j = 0; j <= n; ++j) {
      if (pos[n][j] <= 0) {
        flag = 1;
      }
    }
    if (flag) {
      high = mid;
    } else {
      low = mid;
    }
  }
  cout << ceil(low * 1000) << endl;
  return 0;
}
