#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> A1, A2;
int N, M;
void solve() {
cin >> N >> M;
A1.resize(N); A2.resize(M);
for (auto& a : A1) cin >> a;
for (auto& a : A2) cin >> a;
sort(A1.begin(), A1.end());
sort(A2.begin(), A2.end());
if (N > M) {
swap(N, M);
swap(A1, A2);
}
int ans = 0, frm = 0;
for (int i = 0; i < N; i++) {
int it = lower_bound(A2.begin()+frm, A2.begin()+M-(N-i-1), A1[i]) - A2.begin();
int c1 = (it >= M ? INT_MAX : abs(A1[i] - A2[it])), c2 = (it == frm ? INT_MAX : abs(A1[i] - A2[it-1]));
// cerr << it << ' ' << frm << ' ' << c1 << ' ' << c2 << endl;
if (c1 < c2)
ans = max(ans, c1), frm = it+1;
else
ans = max(ans, c2), frm = it;
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
2636 KB |
Output is correct |
2 |
Incorrect |
42 ms |
2888 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
2884 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
2416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
2612 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
2464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |