#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define all(x) begin(x), end(x)
#define x first
#define y second
typedef long long ll;
typedef long double ld;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using normal_queue = priority_queue<T, vector<T>, greater<T>>;
const int MAX_N = 1e5 + 10;
int a[MAX_N], b[MAX_N];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
int *ca = a, *cb = b;
if (n > m)
swap(ca, cb);
for (int i = 0; i < n; ++i)
cin >> ca[i];
for (int i = 0; i < m; ++i)
cin >> cb[i];
if (n > m)
swap(n, m);
sort(a, a + n);
sort(b, b + n);
int l = -1, r = 1e9 + 1;
while (r - l > 1) {
int mid = (l + r) / 2;
int ptr = 0;
bool flag = 0;
for (int i = 0; i < n; ++i) {
while (ptr < m && abs(a[i] - b[ptr]) > mid)
++ptr;
if (ptr >= m) {
flag = 1;
break;
}
++ptr;
}
if (flag)
l = mid;
else
r = mid;
}
cout << r << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |