#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> point;
const int MAXN = 1e5 + 5;
int n, m;
int a[MAXN], b[MAXN];
bool check(int x){
int curr = 0;
REP(i, m){
while(abs(a[curr] - b[i]) > x && curr < n)
curr ++;
if(curr == n && abs(a[curr] - b[i]) > x)
return false;
curr ++;
}
return true;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> m;
REP(i, n)
cin >> a[i];
REP(i, m)
cin >> b[i];
sort(a, a + n);
sort(b, b + m);
if(n < m){
swap(a, b);
swap(n, m);
}
int lo = 0, hi = 1e9;
while(lo < hi){
int mid = (lo + hi) >> 1;
if(check(mid))
hi = mid;
else
lo = mid + 1;
}
cout << lo;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
2680 KB |
Output is correct |
2 |
Correct |
50 ms |
4608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
6344 KB |
Output is correct |
2 |
Correct |
56 ms |
7908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7908 KB |
Output is correct |
2 |
Incorrect |
5 ms |
7960 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7960 KB |
Output is correct |
2 |
Incorrect |
6 ms |
7960 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
7960 KB |
Output is correct |
2 |
Incorrect |
7 ms |
8088 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
8088 KB |
Output is correct |
2 |
Incorrect |
5 ms |
8088 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8088 KB |
Output is correct |
2 |
Incorrect |
5 ms |
8088 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
8088 KB |
Output is correct |
2 |
Correct |
32 ms |
8088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
8088 KB |
Output is correct |
2 |
Correct |
23 ms |
8088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
9444 KB |
Output is correct |
2 |
Correct |
42 ms |
10832 KB |
Output is correct |