#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
long long int s[n];
long long int f[m];
for(int i = 0; i < n; i++){
cin >> s[i];
}
long long int ans = -1;
for(int i = 0; i < m; i++){
cin >> f[i];
int ans1 = -1;
int l = 0;
int r = n - 1;
while(l <= r){
int mid = (l + r) / 2;
if(s[mid] <= f[i]){
ans1 = max(ans1, mid);
l = mid + 1;
}else{
r = mid - 1;
}
}
long long int mini = 1e18;
if(ans1 != -1){
mini = f[i] - s[ans1];
}
int ans2 = n + 1;
l = 0;
r = n - 1;
while(l <= r){
int mid = (l + r) / 2;
if(s[mid] >= f[i]){
ans2 = min(ans2, mid);
r = mid - 1;
}else{
l = mid + 1;
}
}
if(ans2 != (n + 1)){
mini = min(mini, s[ans2] - f[i]);
}
ans = max(ans, mini);
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |