#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
set<int> s;
int main()
{
ios_base:: sync_with_stdio(false); cin.tie(0);
int n,m; cin>>n>>m;
vector<int> v1(n+1),v2(m+1);
for(int i=1; i<=n; i++) {
cin>>v1[i];
}
for(int i=1; i<=m; i++) {
cin>>v2[i];
}
if(m>n) {
swap(n,m);
swap(v1,v2);
}
for(int i=1; i<=n; i++) {
s.insert(v1[i]);
}
//cout<<endl;
sort(v2.rbegin(),v2.rend()-1);
/*
for(int i=1; i<=m; i++) {
cout<<v2[i]<<" ";
}
cout<<endl;
*/
int ans=0;
for(int i=1; i<=m; i++) {
auto d=s.lower_bound(v2[i]);
auto d2=d;
if(d2!=s.begin()) {
d2--;
}
if(abs(*d-v2[i])<abs(*d2-v2[i])) {
ans=max(ans,abs(*d-v2[i]));
s.erase(d);
}
else{
ans=max(ans,abs(*d2-v2[i]));
s.erase(d2);
}
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
5884 KB |
Output is correct |
2 |
Execution timed out |
1100 ms |
5752 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
5752 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Execution timed out |
1097 ms |
640 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Output is correct |
2 |
Execution timed out |
1096 ms |
640 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
5496 KB |
Output is correct |
2 |
Incorrect |
46 ms |
3576 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
72 ms |
5368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
76 ms |
5240 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |