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){
int pt = 0;
for(auto &i : a){
while(pt < m && b[pt] < i - x) pt++;
if(pt == m) return 0;
if(b[pt] - i > x) return 0;
pt++;
}
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());
sort(b.begin(), b.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... |