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;
typedef long long ll;
const int N = 1e5;
int n, m;
vector<ll> L, R;
bool works(ll x){
int cnt = 0;
for(int i = 0; i < m; i ++){
if(cnt >= n){
return true;
}
if(llabs(R[i] - L[cnt]) > x){
continue;
}
cnt ++;
}
return (cnt >= n);
}
int main() {
cin >> n >> m;
ll num;
for(int i = 0; i < n; i ++){
cin >> num;
L.push_back(num);
}
for(int i = 0; i < m; i ++){
cin >> num;
R.push_back(num);
}
if(n > m){
swap(L, R);
}
n = (int)L.size();
m = (int)R.size();
sort(L.begin(), L.end());
sort(R.begin(), R.end());
ll lo = 0, hi = (1LL << 40LL);
ll ans = -1;
while(lo <= hi){
ll mid = lo + ((hi - lo) / 2LL);
if(works(mid)){
hi = mid -1;
ans = mid;
}
else{
lo = mid +1;
}
}
cout << ans << endl;
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... |