#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long
int n, m;
vector <int> a, b;
bool check(int x){
int pt = 0;
for(auto &i : a){
while(pt < m && b[pt] < i - x) pt++;
if(pt == m) return 0;
if(b[pt] - i > x) return 0;
pt++;
}
return 1;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
a.resize(n);
for(auto &i : a) cin >> i;
b.resize(m);
for(auto &i : b) cin >> i;
if(b.size() < a.size()) swap(a, b);
sort(a.begin(), a.end());
sort(b.begin(), b.end());
int l = 0, r = 1e9;
while(l <= r){
int mid = (l + r) / 2;
if(check(mid)) r = mid - 1;
else l = mid + 1;
}
cout << l << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
1144 KB |
Output is correct |
2 |
Correct |
52 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
1188 KB |
Output is correct |
2 |
Correct |
53 ms |
2840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
1068 KB |
Output is correct |
2 |
Incorrect |
30 ms |
1868 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
1020 KB |
Output is correct |
2 |
Correct |
27 ms |
2040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
1052 KB |
Output is correct |
2 |
Incorrect |
44 ms |
2552 KB |
Output isn't correct |