1 #include <cstdio>
2 #include <iostream>
3 #include <algorithm>
4 #include <iomanip>
5 using namespace std;
6
7 const int N = 1003;
8
9 int main()
10 {
11 cout << setiosflags(ios::fixed) << setiosflags(ios::right) << setprecision(6);
12 int cas,n;
13 cin >> cas;
14 while(cas--){
15 cin >> n;
16 double p[N]={0};
17 int v[N] = {0};
18 int i;
19 for(i = 1 ; i <= n ; ++i){
20 cin >> p[i];
21 }
22 for(i = 1 ; i <= n ; ++i){
23 cin >> v[i];
24 }
25
26 int w = v[1];
27 double t = w;
28 double avg = 0;
29 double sum = 0;
30
31 for(i = 1 ; i <= n ; ++i){
32 sum += p[i];
33 if(w < v[i] - v[i-1])w = v[i] - v[i-1];
34 if(i == n){
35 if(avg * i < sum){
36 avg = sum/i;
37 t = w;
38 }
39 break;
40 }
41 if(w < v[i+1] - v[i] && avg * i < sum){
42 avg = sum/i;
43 t = w;
44 }
45 }
46 cout << t << ' ' << avg << endl;
47 }
48 return 0;
49 }