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 <iostream>
#include <algorithm>
using namespace std;
int n, m, a[100001], b[100001];
bool ver(int x) {
int i = 0, j = 0;
while(i < n && j < m) {
i++;
j++;
while(a[i] - x > b[j] && j < m)
j++;
if(a[i] - x > b[j] || a[i] + x < b[j])
return 0;
}
if(i < n)
return 0;
return 1;
}
int main()
{
cin >> n >> m;
if(n > m) {
swap(n, m);
for(int i=1; i<=m; i++)
cin >> b[i];
for(int i=1; i<=n; i++)
cin >> a[i];
}
else {
for(int i=1; i<=n; i++)
cin >> a[i];
for(int i=1; i<=m; i++)
cin >> b[i];
}
sort(a+1, a+n+1);
sort(b+1, b+m+1);
int st = 0, dr = 1e9, ans = 0;
while(st <= dr) {
int mij = (st + dr) / 2;
if(ver(mij)) {
ans = mij;
dr = mij - 1;
}
else
st = mij + 1;
}
cout << ans;
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... |