Advertisement
Ankit_132

B

Sep 24th, 2023
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll     long long
  7. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  8.  
  9. int main()
  10. {
  11.     _test
  12.     {
  13.         ll int n;
  14.         cin>>n;
  15.  
  16.         vector<ll int> a(n), b(n);
  17.         for(auto &e: a)     cin>>e;
  18.         for(auto &e: b)     cin>>e;
  19.  
  20.         ll int x = (*min_element(a.begin(), a.end()))*n +
  21.                     accumulate(b.begin(), b.end(), 0ll);
  22.  
  23.         ll int y = (*min_element(b.begin(), b.end()))*n +
  24.                     accumulate(a.begin(), a.end(), 0ll);
  25.  
  26.         cout<<min(x, y)<<"\n";
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement