#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N;
cin >> N;
vector<long long> A(N + 1), B(N);
for (int i = 0; i <= N; ++i) {
cin >> A[i];
}
for (int i = 0; i < N; ++i) {
cin >> B[i];
}
sort(B.begin(), B.end());
vector<long long> min_strangeness(N + 1);
for (int i = 0; i <= N; ++i) {
auto it = lower_bound(B.begin(), B.end(), A[i]);
if (it == B.begin()) {
min_strangeness[i] = abs(A[i] - B[0]);
} else if (it == B.end()) {
min_strangeness[i] = abs(A[i] - B[N - 1]);
} else {
int idx = it - B.begin();
min_strangeness[i] = min(abs(A[i] - B[idx]), abs(A[i] - B[idx - 1]));
}
}
for (int i = 0; i <= N; ++i) {
cout << min_strangeness[i] << " ";
}
cout << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |