#include #include #include #include #include #define ll long long #define inf 1e9 #define eps 1e-10 #define md #define N 10010 using namespace std; double h[N],v[N]; inline double P (double x) { return x*x*x;} int main() { int tt,n; scanf("%d",&tt); while (tt--) { scanf("%d",&n); double sum=0,x; for (int i=1;i<=n;i++) scanf("%lf",&h[i]); for (int i=1;i<=n;i++) { scanf("%lf",&x); v[i]=(1.0/3)*h[i]*(x*x); sum+=v[i]; } int l=0,r=1000; while (l!=r) { int mid=(l+r+1)/2; double S=0; for (int i=1;i<=n;i++) { double der=(h[i]-mid); if (der<0) continue; S+=P(der/h[i])*v[i]; } if (S*2>sum) l=mid; else r=mid-1; } //printf("%lf\n",l); printf("%d\n",l); } return 0; }