#include <bits/stdc++.h>
using namespace std;
const int MAXN = 55;
struct point {
  int a, b;
  friend bool operator<(const point &a, const point &b) { return a.a < b.a; }
} pt[MAXN];
int n;
long long dp[2][MAXN][MAXN];
int dx[MAXN], dx_top = 0;
inline bool judge(long long mid) {
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) dp[0][i][j] = dp[1][i][j] = 1e18;
  int now = 0, nxt = 1;
  dp[now][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++)
      for (int k = 0; k + j <= i; k++) {
        if (pt[i + 1].a == pt[i].a) {
          dp[nxt][j][k + 1] = min(dp[nxt][j][k + 1], dp[now][j][k]);
          long long cur =
              dp[now][j][k] + pt[i + 1].a * 10000ll - pt[i + 1].b * mid;
          if (j) dp[nxt][j - 1][k] = min(dp[nxt][j - 1][k], cur);
          dp[nxt][j][k] = min(dp[nxt][j][k], cur);
        } else {
          dp[nxt][j + k][1] = min(dp[nxt][j + k][1], dp[now][j][k]);
          long long cur =
              dp[now][j][k] + pt[i + 1].a * 10000ll - pt[i + 1].b * mid;
          if (j + k) dp[nxt][j + k - 1][0] = min(dp[nxt][j + k - 1][0], cur);
          dp[nxt][j + k][0] = min(dp[nxt][j + k][0], cur);
        }
      }
    swap(now, nxt);
    for (int j = 0; j <= n; j++)
      for (int k = 0; k <= n; k++) dp[nxt][j][k] = 1e18;
  }
  return dp[now][0][0] <= 0;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> pt[i].a;
  for (int i = 1; i <= n; i++) cin >> pt[i].b;
  sort(pt + 1, pt + n + 1);
  long long L = 0, R = 1e11, mid;
  while (L <= R) {
    mid = (L + R) >> 1;
    if (judge(mid))
      R = mid - 1;
    else
      L = mid + 1;
  }
  cout << (R + 1 + 5) / 10 << endl;
  return 0;
}
