#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;
long long f[2][55][5005];
int n;
struct point {
  int a, b;
  bool operator<(const point &rhs) const {
    if (a != rhs.a) return a > rhs.a;
    return b > rhs.b;
  }
} w[55];
long long sa[55], sb[55];
void Min(long long &x, long long y) {
  if (x > y) x = y;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i].a);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i].b);
  sort(w + 1, w + n + 1);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= 5000; j++) f[0][i][j] = f[1][i][j] = INF;
  f[0][0][0] = 0;
  int lst, now;
  lst = 0;
  now = 1;
  for (int i = 1, nxt; i <= n; i = nxt + 1) {
    for (nxt = i + 1; nxt <= n; nxt++)
      if (w[nxt].a != w[i].a) break;
    nxt--;
    int tot = 0;
    for (int j = i; j <= nxt; j++) {
      tot++;
      sa[tot] = sa[tot - 1] + w[j].a;
      sb[tot] = sb[tot - 1] + w[j].b;
    }
    for (int j = 0; j <= nxt; j++)
      for (int k = 0; k <= 5000; k++) f[now][j][k] = INF;
    for (int j = 0; j < i; j++)
      for (int k = 0; k <= 5000; k++)
        if (f[lst][j][k] != INF) {
          for (int x = tot; tot - x <= j && x >= 0; x--)
            Min(f[now][j - (tot - x) + x][k + sb[x]], f[lst][j][k] + sa[x]);
        }
    swap(now, lst);
  }
  double ans = INF;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= 5000; j++)
      if (f[lst][i][j] != INF)
        ans = min(ans, ((double)f[lst][i][j] * 1000 / j));
  printf("%.10f\n", ans);
  cout << (long long)(ans + 1) << endl;
  return 0;
}
