#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
#define f0(i,n) for(int32_t i = 0; i < (n); i++)
#define f1(i,n) for(int32_t i = 1; i <= (n); i++)
#define inp(n) lli n; cin >> n
#define inparr(arr,n) lli arr[n]; f0(t_ind, n) cin >> arr[t_ind]
int main () {
inp(n);
inparr(a, n+1);
inparr(b, n);
sort(a, a+n+1);
sort(b, b+n);
lli prefmx[n], sufmx[n];
prefmx[0] = max(a[0]-b[0], 0ll);
sufmx[n-1] = max(a[n]-b[n-1], 0ll);
for (int32_t i = 1; i < n; i++) {
prefmx[i] = max(prefmx[i-1], a[i]-b[i]);
}
for (int32_t i = n-2; i >= 0; i--) {
sufmx[i] = max(sufmx[i+1], a[i+1]-b[i]);
}
cout << sufmx[0] << " ";
f1(i, n-1) {
cout << max(prefmx[i-1], sufmx[i]) << " ";
}
cout << prefmx[n-1] << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |