n = int(input())
ties = list(map(int, input().split()))
realsus = list(ties)
employees = list(map(int, input().split()))
temp = sorted(ties)
employees.sort()
tiesmap = dict()
for i in range(len(temp)):
tiesmap[temp[i]] = i
sussies = dict()
ties = list(temp)
max1 = [ties[i]-employees[i] for i in range(n)]
max2 = [ties[i]-employees[i-1] for i in range(1, n+1)]
for i in range(1,n):
max1[i] = max(max1[i-1], max1[i])
for i in range(n-2, 1, -1):
max2[i] = max(max2[i+1], max2[i])
sussies[0] = max2[0]
sussies[n] = max1[-1]
for i in range(1,n):
sussies[i] = max(max1[i-1], max2[i])
realsus = [max(0,sussies[tiesmap[i]]) for i in realsus]
print(*realsus)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
18128 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
18128 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
18128 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |