#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; vector> V(N); rep(i,N) cin >> V[i].first; rep(i,N) cin >> V[i].second; sort(V.begin(), V.end()); auto f = [&](ll x) { ll res = 0; for(auto [a, b] : V) res += b * abs(a - x); return res; }; ll cnt = 0, sumB = 0; rep(i,N) sumB += V[i].second; rep(i,N) { cnt += V[i].second; if(cnt >= sumB / 2) { cout << V[i].first << " " << f(V[i].first) << endl; return 0; } } }