#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define N 100500
#define oo ll(1e16)
#define ft first
#define sd second
#define pb push_back
#define ppb pop_back
#define el '\n'
#define elf endl
#define base ll(1e9 + 7)
using namespace std;
typedef long long ll;
typedef long double ld;
int n, m;
vector <int> a, b;
bool gd(int x) {
int p = 0;
for (int i = 0; i < n; i++) {
while (p < m && abs(a[i] - b[p]) > x) p++;
if (p == m)
return 0;
p++;
}
return 1;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// in("input.txt");
cin >> n >> m;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
a.pb(x);
}
for (int i = 0; i < m; i++) {
int x;
cin >> x;
b.pb(x);
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
if (n > m)
swap(a, b), swap(n, m);
int l = 0, r = 1e9;
while (l < r) {
int md = (l + r) >> 1;
if (gd(md)) r = md;
else l = md + 1;
}
cout << l;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
3068 KB |
Output is correct |
2 |
Correct |
53 ms |
3188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
3188 KB |
Output is correct |
2 |
Correct |
55 ms |
3188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
640 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
2812 KB |
Output is correct |
2 |
Correct |
34 ms |
2048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
2932 KB |
Output is correct |
2 |
Correct |
31 ms |
2300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
2812 KB |
Output is correct |
2 |
Correct |
47 ms |
2932 KB |
Output is correct |