#include <bits/stdc++.h>
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 500100
#define pa pair<ll, ll>
#define ld long double
ll a[mn], b[mn], n, m;
ll al =30;
ll solve(ll d){
ll j=0;
loop(i, 0, n){
while(j<m and abs(a[i]-b[j])>d)j++;
if(j>=m or abs(a[i]-b[j])>d) return 0;
j++;
}
return 1;
}
int main(){
cin >> n>> m;
loop(i, 0, n) cin >> a[i];
loop(i, 0, m) cin >> b[i];
sort(a, a+n);
sort(b, b+m);
if(n>m)swap(a, b), swap(n, m);
ll cnt=(1<<al)-1;
pool(i, al, 0) if(solve(cnt-(1<<i)))cnt-=(1<<i);
cout << cnt <<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
146 ms |
3320 KB |
Output is correct |
2 |
Correct |
176 ms |
3704 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
179 ms |
3608 KB |
Output is correct |
2 |
Correct |
178 ms |
3700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
10 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
10 ms |
528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
10 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
10 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
11 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
155 ms |
2916 KB |
Output is correct |
2 |
Correct |
108 ms |
9208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
161 ms |
3288 KB |
Output is correct |
2 |
Correct |
116 ms |
9336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
150 ms |
2936 KB |
Output is correct |
2 |
Correct |
154 ms |
9720 KB |
Output is correct |