/* >>~~ UVa Online Judge ACM Problem Solution ~~<< ID: 10037 Name: Bridge Problem: https://onlinejudge.org/external/100/10037.pdf Language: C++ Author: Arash Shakery Email: arash.shakery@gmail.com */ #include #include #include using namespace std; int n, w[1001], DP[1001], P[1001] = {1, 2}; int main() { int T; cin>>T; while (T--) { cin>>n; for (int i=0; i> w[i]; sort(w, w+n); DP[0] = w[0]; DP[1] = max(w[0], w[1]); for (int i=2; i1; i -= P[i]) { cout << w[0] << endl; if (P[i] == 1) printf("%d %d\n", w[0], w[i]); else { printf("%d %d\n", w[i-1], w[i]); cout << w[1] << endl; printf("%d %d\n", w[0], w[1]); } } if (T) putchar('\n'); } }