from sys import stdin
input = stdin.readline
gi = lambda: tuple(map(int, input().split()))
n = int(input())
arr = gi()
queries = sorted((i, j) for j, i in enumerate(arr))
brr = sorted(gi())
arr.sort()
suf = [0]
for i, val in enumerate(reversed(brr)):
suf.append(max(suf[-1], max(arr[~i] - val, 0)))
ans = [0] * (n + 1)
for i, (val, ind) in enumerate(queries):
if i == 0:
ans[ind] = suf[-1]
pre = max(val - brr[i], 0)
elif i == n:
ans[ind] = pre
else:
ans[ind] = max(pre, suf[~i])
pre = max(pre, max(val - brr[i], 0))
print " ".join(map(str, ans))
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
27 ms |
4960 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
27 ms |
4960 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
27 ms |
4960 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |