-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
39 lines (35 loc) · 1.54 KB
/
test.cpp
File metadata and controls
39 lines (35 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <iostream>
#include <cmath>
#define S(x) scanf("%d",&x)
#define P(x) printf("%d\n",x)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
using namespace std;
typedef long long int LL;
typedef vector<int > VI;
int main() {
int tc;
S(tc);
while(tc--) {
int n;
scanf("%d",&n);
int A[n];
rep(i,0,n) scanf("%d",&A[i]);
sort(A,A+n);
int mx = A[0]+A[n-1];
int mn = A[0]+A[n-1];
rep(i,0,n/2) {
mx = max(mx,A[i]+A[n-1-i]);
mn = min(mn,A[i]+A[n-1-i]);
}
printf("%d\n",mx-mn);
}
return 0;
}