fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5. int main() {
  6. ios::sync_with_stdio(false);
  7. cin.tie(0);
  8.  
  9. int n; cin >> n;
  10. vector<ll> a(n), b(n);
  11. for (ll &x : a) cin >> x;
  12. for (ll &x : b) cin >> x;
  13.  
  14. sort(a.begin(), a.end());
  15. sort(b.begin(), b.end());
  16.  
  17. ll sum = 0;
  18. for (int i = 0; i < n; i++) sum += a[i] * b[i];
  19.  
  20. cout << sum << "\n";
  21. }
  22.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
0