Submission #245544

# Submission time Handle Problem Language Result Execution time Memory
245544 2020-07-06T17:19:45 Z zecookiez Just Long Neckties (JOI20_ho_t1) PyPy
0 / 100
32 ms 5088 KB
from sys import stdin
input = stdin.readline
gi = lambda: map(int, input().split())
n = int(input())
arr = gi()
queries = sorted((i, j) for j, i in enumerate(arr))
brr = gi()
arr.sort()
brr.sort()

pre = [1e18] * n
suf = [1e18] * n
pre[0] = max(arr[0] - brr[0], 0)
for i in xrange(1, n):
    pre[i] = max(pre[i - 1], max(arr[i] - brr[i], 0))
suf[n - 1] = max(arr[-1] - brr[-1], 0)
for i in xrange(n - 2, -1, -1):
    suf[i] = max(suf[i + 1], max(arr[i + 1] - brr[i], 0))
ans = []
for _, i in queries:
    if i == 0:
        ans.append(suf[0])
    elif i == n:
        ans.append(pre[-1])
    else:
        ans.append(max(pre[i - 1], suf[i]))
print " ".join(map(str, ans))
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 5088 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 5088 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 5088 KB Output isn't correct
2 Halted 0 ms 0 KB -