#include <bits/stdc++.h>
using namespace std;
FILE *in, *out;
int N, M, K;
vector<pair<int, int> > ar(55);
double dp[55][55];
double vals[55];
int used[55][55];
double first(int pos, int av) {
  if (pos >= N) return 0.0000;
  if (used[pos][av]) return dp[pos][av];
  int i, j, k;
  int pos_end = -1;
  vector<pair<double, int> > pot;
  double sum = 0.00000;
  for (i = pos; i < N && ar[pos].first == ar[i].first; i++) {
    pot.push_back(make_pair(vals[i], i));
    sum += vals[i];
  }
  pos_end = i;
  sort(pot.begin(), pot.end());
  double ans = ((1 << 30) - 1);
  ans = min(ans, first(pos_end, av + (int)(pot).size()) + sum);
  for (i = (int)(pot).size() - 1, j = 0; i >= 0 && j < av; i--, j++) {
    sum -= pot[i].first;
    ans = min(ans, first(pos_end, av - j - 1 + i) + sum);
  }
  used[pos][av] = 1;
  dp[pos][av] = ans;
  return ans;
}
int check(double th) {
  int i, j, k;
  for (i = 0; i <= N; i++) {
    for (j = 0; j <= N; j++) {
      used[i][j] = 0;
    }
  }
  for (i = 0; i < N; i++) {
    vals[i] = ((double)ar[i].first) - th * ((double)ar[i].second);
  }
  double ans = first(0, 0);
  if (ans <= 0.00000) return 1;
  return 0;
}
int read() {
  int i, j, k;
  fscanf(in, "%d", &N);
  ar.resize(N);
  int A = 0;
  for (i = 0; i < N; i++) {
    fscanf(in, "%d", &ar[i].first);
    A += ar[i].first;
  }
  int B = 0;
  for (i = 0; i < N; i++) {
    fscanf(in, "%d", &ar[i].second);
    B += ar[i].second;
  }
  sort(ar.begin(), ar.end());
  reverse(ar.begin(), ar.end());
  double minx = 0.00000, maxx = A, midx;
  while (abs(minx - maxx) > 1e-9) {
    midx = (minx + maxx) / 2.000;
    if (check(midx))
      maxx = midx;
    else
      minx = midx;
  }
  int ans = ceil(minx * 1000);
  printf("%d\n", ans);
  return 0;
}
int main() {
  in = stdin;
  out = stdout;
  read();
  return 0;
}
