fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long minimizeSumofProduct(vector<int> a, vector<int> b){
  5. int n = a.size();
  6. sort(a.begin(), a.end());
  7. sort(b.begin(), b.end(), greater<int>());
  8.  
  9. long long sum = 0;
  10. for(int i = 0; i < n; i++){
  11. sum += a[i]*b[i]*1ll;
  12. }
  13.  
  14. return sum;
  15. }
  16.  
  17. int main() {
  18. // your code goes here
  19. vector<int> a = {1, 8, 5};
  20. vector<int> b = {-1, 0, 80};
  21.  
  22. cout << minimizeSumofProduct(a, b);
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
72