#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];
deque<pair<int,int> > p;
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 minn=1e9+4;
int mas=-1;
/*for(int i=0;i<=n-m;i++){
while(!p.empty()&&p.front().fi<abs(va[i]-vb[i]))p.pop_front();
p.push_front(abs(va[i]-vb[i]));
int mas=-1;
for(int y=0;y<m;y++){
mas=max(mas,abs(va[i+y]-vb[y]));
}
minn=min(minn,mas);
}*/
int ind=0;
for(int i=0;i<m;i++){
int minp=1e9+4;
int indp;
for(int y=ind;y<=n-(m-i);y++){
if(abs(va[y]-vb[i])<minp){
minp=abs(va[y]-vb[i]);
indp=y+1;
}
}
mas=max(mas,minp);
}
cout<<mas;
/*minn=min(minn,p.back().fi);
for(int i=0;i<va.size();i++){
if(!p.empty()&&p.back().se==i-vb.size())p.pop_back();
while(p.front().fi<abs())
}*/
//cout<<minn;
}
Compilation message
cipele.cpp: In function 'int main()':
cipele.cpp:49:9: warning: variable 'indp' set but not used [-Wunused-but-set-variable]
int indp;
^~~~
cipele.cpp:35:7: warning: unused variable 'minn' [-Wunused-variable]
int minn=1e9+4;
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1062 ms |
1272 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1053 ms |
1164 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1144 KB |
Output is correct |
2 |
Incorrect |
26 ms |
1144 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1144 KB |
Output is correct |
2 |
Incorrect |
27 ms |
1272 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1144 KB |
Output is correct |
2 |
Incorrect |
26 ms |
1152 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
1144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1064 ms |
1204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1075 ms |
1116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1044 ms |
1080 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |