-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathacpc11b.cpp
More file actions
43 lines (41 loc) · 783 Bytes
/
acpc11b.cpp
File metadata and controls
43 lines (41 loc) · 783 Bytes
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
40
41
42
43
#include <iostream>
#include <cstring> //memset
#include <algorithm>
#include <bitset>
#include <string>
#include <vector>
#include <utility>
#include <cstdio>
#include <queue>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
int main() {
freopen("input.txt", "r", stdin);
int test_cases, n1, n2;
cin >> test_cases;
while (test_cases--) {
cin >> n1;
int alt1[n1];
for (int i = 0; i < n1; ++i) {
cin >> alt1[i];
}
// sort(alt1, alt1+n1);
cin >> n2;
int alt2[n2];
for (int i = 0; i < n2; ++i) {
cin >> alt2[i];
}
// sort(alt2, alt2+n2);
int diff = 1000000;
for (int i = 0; i < n1; ++i) {
for (int j = 0; j < n2; ++j) {
diff = min(diff, abs(alt1[i]-alt2[j]));
}
}
cout << diff << endl;
}
return 0;
}