#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ifstream in("input.txt");
ofstream out("output.txt");
typedef long long ll;
int n,m;
int va[100001];
int vb[100001];
bool funz(int k){
int indp=0;
for(int i=0;i<m;i++){
bool flag=0;
for(int y=indp;y<n;y++){
if(abs(va[y]-vb[i])<=k){
flag=1;
indp=y+1;
break;
}
}
if(!flag)return 0;
}
return 1;
}
int main(){
cin>>n>>m;
for(int i=0;i<n;i++)cin>>va[i];
for(int i=0;i<m;i++)cin>>vb[i];
sort(va,va+n);
sort(vb,vb+m);
if(n<m){
swap(va,vb);
swap(n,m);
}
int s=0;
int d=1e9+4;
int minn=1e9+4;
while(s<=d){
int k=(s+d)/2;
if(funz(k)){
minn=min(minn,k);
d=k-1;
}
else{
s=k+1;
}
}
cout<<minn;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
132 ms |
1144 KB |
Output is correct |
2 |
Correct |
169 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
160 ms |
1144 KB |
Output is correct |
2 |
Correct |
162 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1144 KB |
Output is correct |
2 |
Correct |
11 ms |
1088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1144 KB |
Output is correct |
2 |
Correct |
11 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1188 KB |
Output is correct |
2 |
Correct |
11 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1144 KB |
Output is correct |
2 |
Correct |
11 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1144 KB |
Output is correct |
2 |
Correct |
11 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
1024 KB |
Output is correct |
2 |
Correct |
93 ms |
1760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
147 ms |
1144 KB |
Output is correct |
2 |
Correct |
98 ms |
2120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
134 ms |
1244 KB |
Output is correct |
2 |
Correct |
136 ms |
2552 KB |
Output is correct |