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 <bits/stdc++.h>
using namespace std;
#define N (int)1e9 + 1
#define all(x) x.begin(), x.end()
int main() {
#ifdef judge
ifstream cin("input.txt");
//ofstream cout("output.txt");
#endif // judge
ios_base :: sync_with_stdio(0);
cin.tie(0) , cout.tie(0);
int n , m;
cin >> n >> m;
vector<int> a(n) , b(m);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < m; i++) {
cin >> b[i];
}
sort(all(a)) , sort(all(b));
if (n > m) {
swap(n , m);
swap(a , b);
}
auto can = [&](int x) {
bool ok = true;
int j = 0;
for (int i = 0; i < n; i++) {
while (j < m && abs(a[i] - b[j]) > x) {
j++;
}
if (j >= m) {
ok = false;
break;
}
j++;
}
return ok;
};
int l = 0 , r = N;
while (l != r) {
int mid = (l + r) >> 1;
if (can(mid))
r = mid;
else
l = mid + 1;
}
cout << r << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |