#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
const int NMAX = 1e5;
int n,m;
int a[NMAX + 5];
int b[NMAX + 5];
bool ok(int val){
int last = 1;
for(int i = 1;i <= n;i++){
while(last <= m && a[i] - b[last] > val){
last++;
}
if(last > m){
return false;
}
if(a[i] + val < b[last]){
return false;
}
last++;
}
return true;
}
int main(){
cin >> n >> m;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
for(int i = 1;i <= m;i++){
cin >> b[i];
}
if(n > m){
for(int i = 1;i <= n || i <= m;i++){
swap(a[i],b[i]);
}
swap(n,m);
}
sort(a + 1,a + 1 + n);
sort(b + 1,b + 1 + m);
int st = -1,dr = 1e9;
while(dr - st > 1){
int mid = (st + dr) / 2;
if(ok(mid)){
dr = mid;
}
else{
st = mid;
}
}
cout << dr;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
2680 KB |
Output is correct |
2 |
Correct |
114 ms |
4544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
6312 KB |
Output is correct |
2 |
Correct |
119 ms |
7988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
7988 KB |
Output is correct |
2 |
Correct |
8 ms |
7988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7988 KB |
Output is correct |
2 |
Correct |
9 ms |
7988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
7988 KB |
Output is correct |
2 |
Correct |
8 ms |
7988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7988 KB |
Output is correct |
2 |
Correct |
8 ms |
7988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
7988 KB |
Output is correct |
2 |
Correct |
7 ms |
7988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
7988 KB |
Output is correct |
2 |
Correct |
68 ms |
7988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
102 ms |
7988 KB |
Output is correct |
2 |
Correct |
66 ms |
8544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
9028 KB |
Output is correct |
2 |
Correct |
108 ms |
10528 KB |
Output is correct |