#include int n; int A[11000],B[11000]; double getV(double r,double h) { return r * r * h / 6.0; } double getS(double H) { double S = 0.0; for(int i=0;i H ) { double h = A[i] - H; double r = h * ( (double)B[i]/(double)A[i] ); S += getV(r,h); } return S; } int main() { int T; scanf("%d",&T); while( T-- ) { int mx = 0; double V = 0.0; scanf("%d",&n); for(int i=0;i mx ) mx = A[i]; V += getV(B[i],A[i]); } double l = 0.0,r = mx; while( r-l > 0.001 ) { double m = (l+r)/2; //printf(">> %.4lf :: %.4lf\n",getS(m)/V,m); if( getS(m) > (V/2.0) ) l = m; else r = m; } //fprintf(stderr,"%.3lf\n",(l+r)/2); printf("%d\n",(int)((l+r)/2)); } return 0; }