Ankit_132

EVacuate to Moon

Jun 21st, 2023
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int t;
  6.     cin>>t;
  7.    
  8.     while(t--)
  9.     {
  10.         long long int n, m, h;
  11.         cin>>n>>m>>h;
  12.        
  13.         vector<long long int> car(n);
  14.         for(auto &e: car)           cin>>e;
  15.         vector<long long int> outlet(m);
  16.         for(auto &e: outlet)        cin>>e;
  17.        
  18.         sort(car.rbegin(), car.rend());
  19.         sort(outlet.rbegin(), outlet.rend());
  20.        
  21.         long long int ans = 0;
  22.        
  23.         for(int i=0, j=0; i<n && j<m; i++, j++)
  24.             ans += min({car[i], h*outlet[j]});
  25.            
  26.        cout<<ans<<"\n";
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment