Advertisement
Ankit_132

A

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