#include <bits/stdc++.h>
using namespace std;
const double inf = 1e40;
const int maxn = 53;
double f[maxn][maxn][maxn];
struct Task {
  int a, b;
  bool operator<(const Task& t) const { return a > t.a || a == t.a && b > t.b; }
} tasks[maxn];
int n;
bool dp(double bv) {
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        f[i][j][k] = inf;
        if (k && f[i - 1][j][k - 1] != inf)
          f[i][j][k] = min(f[i][j][k],
                           f[i - 1][j][k - 1] + tasks[i].a - tasks[i].b * bv);
        if (j < n) f[i][j][k] = min(f[i][j][k], f[i - 1][j + 1][k]);
        if (i == n && f[i][j][k] <= 0 && f[i][j][k] != inf) return true;
        if (tasks[i].a != tasks[i + 1].a && j >= k)
          f[i][j][0] = min(f[i][j][0], f[i][k][j - k]);
      }
    }
    if (tasks[i].a != tasks[i + 1].a) {
      for (int j = 0; j <= n; j++) {
        for (int k = 1; k <= n; k++) {
          f[i][j][k] = inf;
        }
      }
    }
  }
  return false;
}
int main() {
  scanf("%d", &n);
  long long suma = 0;
  int sumb = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &tasks[i].a);
    suma += tasks[i].a;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &tasks[i].b);
    sumb += tasks[i].b;
  }
  for (int j = 0; j <= n; j++)
    for (int k = 0; k <= n; k++) f[0][j][k] = inf;
  f[0][0][0] = 0;
  sort(tasks + 1, tasks + n + 1);
  tasks[0].a = 1e8 + 1;
  long long l = 0, r = suma * 100000.0 / sumb + 1;
  while (l < r) {
    long long m = (l + r) / 2;
    if (dp(m / 100000.0))
      r = m;
    else
      l = m + 1;
  }
  cout << long long(ceil(l / 100.0) - 1e-2) << endl;
  return 0;
}
