#include using namespace std; #define int long long typedef pair P; int INF = 1e9+7; int mod = 1e9+7; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int N; double f(double x,vectora,vectorb) { double res = 0; for(int i = 0; i < N; i++) { res += abs(x-a[i])*b[i]; } return res; } signed main() { cin >> N; vectorA(N),B(N); for(int i = 0; i < N; i++) { cin >> A[i]; } for(int i = 0; i < N; i++) { cin >> B[i]; } double low = -INF,high = INF; int time = 1000; while (time--) { double c1 = (low*2+high)/3; double c2 = (low+high*2)/3; if(f(c1,A,B) > f(c2,A,B)) { low = c1; } else { high = c2; } } cout << high << " " << f(high,A,B) << endl; }