#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int n; long long a[200020], b[200020]; long long check(long long x) { long long ans = 0; for (int i = 0; i < n; i++) { ans += b[i] * abs(x - a[i]); } return ans; } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; } long long low = -1000000007, high = 1000000007; int co = 500; while (co--) { long long mid1 = (low * 2 + high) / 3; long long mid2 = (low + high * 2) / 3; if (check(mid1) > check(mid2)) { low = mid1; } else { high = mid2; } } cout << high << " " << check(high) << endl; }