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>
#include<iostream>
#include<bitset>
#include<algorithm>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define pb push_back
#define N 100005
bitset<N> var;
int main(){
lalala;
int n,m;
vector<int> a,b;cin>>n>>m;
for(int i=0;i<n;i++){
int aa;cin>>aa;
a.pb(aa);
}
for(int i=0;i<m;i++){
int bb;cin>>bb;
b.pb(bb);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
if(n>m){
swap(n,m);swap(a,b);
}
int l=0,r=1000000000;
while(l<=r){
int mid=(l+r)/2;
int ok=0;
for(int i=0;i<m;i++){
if(ok==n){
break;
}
if(abs(b[i]-a[ok])<=mid){
ok++;
}
}
if(ok==n){
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... |