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[100005], b[100005];
bool distval(int d){
int j = 0;
for(int i = 0; i < n ; ++i){
while(j < m && b[j] < a[i] - d){
j++;
}
if(j == m)
return 0;
if(b[j] > a[i] + d)
return 0;
j++;
}
return 1;
}
void solve(){
int l = 0, h = 1e9;
while(l < h){
int mid = (l + h) / 2;
if(distval(mid)){
h = mid;
}
else{
l = mid + 1;
}
}
cout << l << endl;
}
int main ()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i = 0 ; i < n ; ++i){
cin >> a[i];
}
sort(a, a + n);
for(int i = 0 ; i < m ; ++i){
cin >> b[i];
}
sort(b, b + m);
if(n > m){
swap(n, m);
swap(a, b);
}
solve();
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... |