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;
const int N = 5e5 + 1, MOD = 1e9 + 9;
typedef long long ll;
int n,m,a[N],b[N];
bool f(int mid){
int it = 1;
for(int i = 1;i <= n;i++){
while(it <= m && abs(b[it] - a[i]) > mid)
it++;
if(it > m) return false;
it++;
}
return 1;
}
void test(){
cin >> n >> m;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
for(int i = 1;i <= m;i++){
cin >> b[i];
}
if(n > m){
for(int i = 1;i <= n;i++){
swap(a[i],b[i]);
}
swap(n,m);
}
sort(a + 1,a + n + 1);
sort(b + 1,b + m + 1);
ll l = -1,r = 2e9;
while(r - l > 1){
ll mid = (l + r) >> 1;
if(f(mid)){
r = mid;
}else{
l = mid;
}
}
cout << r;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int T = 1;//cin >> T;
while (T--) test();
}
# | 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... |