#include <bits/stdc++.h>
using namespace std;
int N;
int neck[200005];
int A[200005];
int bacc[200005];
int fron[200005];
int ans[200005];
int main() {
ios_base::sync_with_stdio(0);
cin >> N;
for(int i = 1; i <= N + 1; i++) {
cin >> neck[i];
}
for(int i = 1; i <= N; i++) {
cin >> A[i];
}
sort(neck + 1, neck + N + 2);
sort(A + 1, A + N + 1);
for(int i = 1; i <= N; i++) {
ans[i + 1] = max(neck[i] - A[i], 0);
ans[i + 1] = max(ans[i], ans[i + 1]);
}
int bef = 0;
for(int i = N; i > 0; i--) {
bef = max(neck[i + 1] - A[i], bef);
ans[i] = max(ans[i], bef);
}
for(int i = 1; i <= N + 1; i++) {
cout << ans[i] << " ";
}
cin >> N;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |