Submission #245554

#TimeUsernameProblemLanguageResultExecution timeMemory
245554zecookiezJust Long Neckties (JOI20_ho_t1)Pypy 2
100 / 100
994 ms57376 KiB
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 = 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))
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...