#include <bits/stdc++.h>
const double Pi = acos(-1.0);
using namespace std;
const long long inf = 1LL << 33;
int n;
pair<long long, long long> task[55];
bool cmp(const pair<long long, long long> &a,
         const pair<long long, long long> &b) {
  return a.first > b.first;
}
double cost[55], dp[55][55];
bool check() {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) dp[i][j] = inf;
  }
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int j = i; j <= n && task[j].first == task[i].first; j++) cnt++;
    double sum = 0;
    for (int j = 0; j <= cnt; j++) {
      for (int k = cnt - j; k + j <= n; k++) {
        if (dp[i - 1][k] == inf) continue;
        dp[i + cnt - 1][k + j - (cnt - j)] =
            min(dp[i + cnt - 1][k + j - (cnt - j)], dp[i - 1][k] + sum);
      }
      if (j < cnt) sum += cost[i + j];
    }
    i += cnt - 1;
  }
  for (int i = 0; i <= n; i++) {
    if (dp[n][i] <= 0) return true;
  }
  return false;
}
int main(int argc, char **argv) {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &task[i].first);
  for (int i = 1; i <= n; i++) scanf("%lld", &task[i].second);
  sort(task + 1, task + n + 1, cmp);
  double l = 0, r = 1e8, m;
  while (r - l > 1e-5) {
    m = (l + r) / 2;
    for (int i = 1; i <= n; i++)
      cost[i] = (double)task[i].first - m * task[i].second;
    if (check())
      r = m;
    else
      l = m;
  }
  printf("%.0lf", ceil(l * 1000));
  return 0;
}
