#include <bits/stdc++.h>
using namespace std;
const int M = 55;
const long long MAX = 1e12;
int n;
struct Task {
  long long A, B;
  Task() {}
  Task(long long a, long long b) : A(a), B(b) {}
  bool operator<(const Task &a) const {
    return A > a.A || (A == a.A && B > a.B);
  }
} P[M];
long long F[M][M], tot[M];
bool check(long long ans) {
  memset(F, 127 / 2, sizeof(F));
  F[0][0] = 0;
  for (int i = 1, j; i <= n; i = j) {
    for (j = i; P[j].A == P[i].A && j <= n; j++)
      ;
    for (int k = i; k < j; k++)
      tot[k - i + 1] = tot[k - i] + P[k].A - P[k].B * ans;
    for (int k = 0; k <= n; k++)
      for (int w = 0, sz = min(k, j - i); w <= sz; w++)
        F[j - 1][(k - w) + (j - i) - w] = min(F[j - 1][(k - w) + (j - i) - w],
                                              F[i - 1][k] + tot[(j - i) - w]);
  }
  for (int i = 0; i <= n; i++)
    if (F[n][i] <= 0) return 1;
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &P[i].A), P[i].A *= 1000ll;
  for (int i = 1; i <= n; i++) scanf("%I64d", &P[i].B);
  sort(P + 1, P + n + 1);
  long long l = 0, r = MAX, mid, ans = 0;
  while (l <= r) {
    mid = l + r >> 1;
    if (check(mid))
      r = mid - 1, ans = mid;
    else
      l = mid + 1;
  }
  printf("%I64d\n", ans);
  return 0;
}
