#include <bits/stdc++.h>
using namespace std;
void qmax(int &x, int y) {
  if (x < y) x = y;
}
void qmin(int &x, int y) {
  if (x > y) x = y;
}
int read() {
  char s;
  int k = 0, base = 1;
  while ((s = getchar()) != '-' && s != EOF && !(isdigit(s)))
    ;
  if (s == EOF) exit(0);
  if (s == '-') base = -1, s = getchar();
  while (isdigit(s)) {
    k = k * 10 + (s ^ '0');
    s = getchar();
  }
  return k * base;
}
void write(int x) {
  if (x < 0) {
    putchar('-');
    write(-x);
  } else {
    if (x / 10) write(x / 10);
    putchar(x % 10 + '0');
  }
}
const int maxn = 55;
const int inf = 0x7fffffff;
int n;
struct node {
  double x, y;
} a[maxn];
bool cmp(node aa, node bb) { return aa.x > bb.x; }
double dp[maxn][maxn][maxn], X;
bool vis[maxn][maxn][maxn];
double dfs(int x, int y, int z) {
  if (x == n + 1) return 0;
  if (vis[x][y][z]) return dp[x][y][z];
  double qwq = inf;
  vis[x][y][z] = 1;
  if (x < n && a[x].x == a[x + 1].x) {
    if (y > 0) qwq = min(qwq, dfs(x + 1, y - 1, z));
    qwq = min(qwq, dfs(x + 1, y, z + 1) + a[x].x - X * a[x].y);
  } else if (x == n || a[x].x != a[x + 1].x) {
    if (y > 0) qwq = dfs(x + 1, y + z - 1, 0);
    qwq = min(qwq, dfs(x + 1, y + z + 1, 0) + a[x].x - X * a[x].y);
  }
  dp[x][y][z] = qwq;
  return qwq;
}
bool check(double x) {
  X = x;
  memset(vis, 0, sizeof(vis));
  return dfs(1, 0, 0) <= 0;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i].x = read();
  for (int i = 1; i <= n; i++) a[i].y = read();
  sort(a + 1, a + n + 1, cmp);
  double r = 100000000.0;
  double l = 0.0;
  for (int T = 1; T <= 100; T++) {
    double mid = (l + r) / 2.0;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  long long ans = ceil(l * 1000);
  cout << ans;
  return 0;
}
