fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8.  
  9. vector<int> a={2,2,3,1};
  10.  
  11. vector<int> b={3,2,1,4};
  12.  
  13. sort(a.begin(), a.end());
  14. sort(b.begin(), b.end(), greater<int>());
  15. int sum=0;
  16. for(int i=0; i<a.size(); i++){
  17. sum+= a[i]*b[i];
  18. }
  19.  
  20. cout<< sum;
  21. return 0;
  22. }
Success #stdin #stdout 0s 5312KB
stdin
4 16
stdout
17