#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(A.begin(), A.end());
sort(B.begin(), B.end());
vector<long long> prefix_min_strangeness(N + 2, 0), suffix_min_strangeness(N + 2, 0);
long long curr_min = 0;
for (int i = 1; i <= N; ++i) {
prefix_min_strangeness[i] = max(A[i] - B[0], curr_min);
curr_min = min(curr_min, prefix_min_strangeness[i]);
}
curr_min = 0;
for (int i = N; i >= 1; --i) {
suffix_min_strangeness[i] = max(A[i] - B[N-1], curr_min);
curr_min = min(curr_min, suffix_min_strangeness[i]);
}
for (int i = 1; i <= N + 1; ++i) {
long long min_strangeness = min(prefix_min_strangeness[i-1], suffix_min_strangeness[i]);
cout << min_strangeness << " ";
}
cout << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |