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 finish(x) return cout << x << endl, 0
#define ll long long
int n, m;
vector <int> a, b;
bool check(int x){
set <int> s(b.begin(), b.end());
for(auto &i : a){
auto it = s.lower_bound(i - x);
if(it == s.end()) return 0;
if(*it - i > x) return 0;
s.erase(it);
}
return 1;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
a.resize(n);
for(auto &i : a) cin >> i;
b.resize(m);
for(auto &i : b) cin >> i;
if(b.size() < a.size()) swap(a, b);
sort(a.begin(), a.end());
int l = 0, r = 1e9;
while(l <= r){
int mid = (l + r) / 2;
if(check(mid)) r = mid - 1;
else l = mid + 1;
}
cout << l << endl;
}
# | 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... |