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 ll long long
#define ar array
int n, m, a[100000], b[100000];
bool ok(int x) {
int c = 0;
for (int i = 0, j = 0; i < n; ++i) {
while(j < m && b[j] + x < a[i])
++j;
if (j == m)
break;
if (a[i] + x >= b[j])
++c, ++j;
}
return c == min(n, m);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; ++i)
cin >> a[i];
for (int i = 0; i < m; ++i)
cin >> b[i];
sort(a, a + n);
sort(b, b + m);
int l = 0, r = 1e9;
while(l < r) {
int mid = (l + r) / 2;
if (ok(mid))
r = mid;
else
l = mid + 1;
}
cout << l;
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... |