#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
double dp[55][55][55];
bool vis[55][55][55];
int a[55], b[55], n;
struct node {
  int va, vb;
  node(int _va = 0, int _vb = 0) : va(_va), vb(_vb) {}
  bool operator<(const node &rhs) const {
    return va != rhs.va ? va > rhs.va : vb > rhs.vb;
  }
} nodes[55];
double dfs(int i, int j, int k, double x) {
  if (i == n) return 0;
  if (vis[i][j][k]) return dp[i][j][k];
  double now = 1e18;
  vis[i][j][k] = true;
  if (i < n - 1 && a[i] == a[i + 1]) {
    now = min(now, dfs(i + 1, j, k + 1, x) + a[i] - b[i] * x);
    if (j) now = min(dfs(i + 1, j - 1, k, x), now);
  } else if (i == n - 1 || a[i] > a[i + 1]) {
    now = min(now, dfs(i + 1, j + k + 1, 0, x) + a[i] - b[i] * x);
    if (j) now = min(dfs(i + 1, j + k - 1, 0, x), now);
  }
  return dp[i][j][k] = now;
}
bool judge(double x) {
  memset(vis, 0, sizeof(vis));
  memset(dp, 0, sizeof(dp));
  double now = dfs(0, 0, 0, x);
  return now <= 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &nodes[i].va);
  for (int i = 0; i < n; i++) scanf("%d", &nodes[i].vb);
  sort(nodes, nodes + n);
  for (int i = 0; i < n; i++) {
    a[i] = nodes[i].va;
    b[i] = nodes[i].vb;
  }
  double l = 0, r = 1e10, mid;
  while (fabs(r - l) > eps) {
    mid = (l + r) / 2;
    if (judge(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%.0f\n", ceil(l * 1000));
}
