# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83455 | charlies_moo | Cipele (COCI18_cipele) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
int n, m;
scanf("%d %d", &n, &m);
int *a = new int[n];
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
int *b = new int[m];
for (int i = 0; i < m; i++) {
scanf("%d", &b[i]);
}
sort(a, a+n);
sort(b, b+m);
if (n > m) {
swap(n, m);
swap(a, b)
}
int l = -1, r = 1e9+1;
while (r - l > 1) {
int mi = (l + r) / 2;
bool flag = true;
int j = 0;
for (int i = 0; i < n; i++) {
while (j < m && b[j] < a[i] - mi) {
j++;
}
if (j == m || b[j] > a[i] + mi) {
flag = false;
break;
}
j++;
}
if (flag) {
r = mi;
} else {
l = mi;
}
}
printf("%d\n", r);
return 0;
}