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