Skip to content

Instantly share code, notes, and snippets.

@trhgquan
Last active October 27, 2019 13:45
Show Gist options
  • Save trhgquan/c14702ccae0cd8f28ce04a36c462048e to your computer and use it in GitHub Desktop.
Save trhgquan/c14702ccae0cd8f28ce04a36c462048e to your computer and use it in GitHub Desktop.
For more algorithm, visit https://github.com/trhgquan/CPP
/**
* SMPAIR - https://codechef.com/problems/SMPAIR
* Code by @trhgquan - https://github.com/trhgquan
*/
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int T, n; cin >> T;
while (T--) {
cin >> n;
vector<int>a;
for (int i = 0; i < n; ++i) {int u; cin >> u; a.push_back(u);}
sort(a.begin(), a.end());
cout << a[0] + a[1] << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment