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;
int n,m;
int arr[100001];
int brr[100001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m;
for (int i=0;i<n;i++) cin>>arr[i];
for (int i=0;i<m;i++) cin>>brr[i];
sort(arr,arr+n);
sort(brr,brr+m);
int mini=-1,maxi=1000000000;
while (mini+1<maxi){
int middle=(mini+maxi)/2;
int apos=0,bpos=0,taken=0;
while (apos<n && bpos<m){
if (abs(arr[apos]-brr[bpos])<=middle){
apos++;
bpos++;
taken++;
}
else if (arr[apos]<brr[bpos]) apos++;
else bpos++;
}
if (taken==min(m,n)) maxi=middle;
else mini=middle;
}
cout<<maxi;
}
# | 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... |