#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> 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];
}
vector<int> order(N + 1);
iota(order.begin(), order.end(), 0);
sort(order.begin(), order.end(), [&](int i, int j) {
return A[i] < A[j];
});
sort(B.begin(), B.end());
vector<int> pref(N + 1), suff(N + 1);
for (int i = 0; i < N; i++) {
pref[i + 1] = max(pref[i], A[order[i]] - B[i]);
}
for (int i = N - 1; i >= 0; i--) {
suff[i] = max(suff[i + 1], A[order[i + 1]] - B[i]);
}
for (int i = 0; i <= N; i++) {
cout << max(pref[order[i]], suff[order[i]]) << " \n"[i == N];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |