Submission #245552

# Submission time Handle Problem Language Result Execution time Memory
245552 2020-07-06T17:39:43 Z zecookiez Just Long Neckties (JOI20_ho_t1) PyPy
9 / 100
1000 ms 55580 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()

suf = [1e18] * n
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 = [0] * (n + 1)
for i, (val, ind) in enumerate(queries):
    if i == 0:
        ans[ind] = suf[0]
        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 time Memory Grader output
1 Correct 26 ms 4960 KB Output is correct
2 Correct 27 ms 4960 KB Output is correct
3 Correct 26 ms 4960 KB Output is correct
4 Correct 28 ms 5080 KB Output is correct
5 Correct 28 ms 4960 KB Output is correct
6 Correct 26 ms 4952 KB Output is correct
7 Correct 29 ms 4960 KB Output is correct
8 Correct 30 ms 4960 KB Output is correct
9 Correct 26 ms 4960 KB Output is correct
10 Correct 26 ms 4960 KB Output is correct
11 Correct 26 ms 4960 KB Output is correct
12 Correct 26 ms 4960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 4960 KB Output is correct
2 Correct 27 ms 4960 KB Output is correct
3 Correct 26 ms 4960 KB Output is correct
4 Correct 28 ms 5080 KB Output is correct
5 Correct 28 ms 4960 KB Output is correct
6 Correct 26 ms 4952 KB Output is correct
7 Correct 29 ms 4960 KB Output is correct
8 Correct 30 ms 4960 KB Output is correct
9 Correct 26 ms 4960 KB Output is correct
10 Correct 26 ms 4960 KB Output is correct
11 Correct 26 ms 4960 KB Output is correct
12 Correct 26 ms 4960 KB Output is correct
13 Correct 31 ms 4960 KB Output is correct
14 Correct 37 ms 5336 KB Output is correct
15 Correct 52 ms 7856 KB Output is correct
16 Correct 32 ms 5080 KB Output is correct
17 Correct 47 ms 6488 KB Output is correct
18 Correct 43 ms 5976 KB Output is correct
19 Correct 46 ms 5976 KB Output is correct
20 Correct 43 ms 5976 KB Output is correct
21 Correct 43 ms 5976 KB Output is correct
22 Correct 43 ms 5976 KB Output is correct
23 Correct 48 ms 5976 KB Output is correct
24 Correct 43 ms 5976 KB Output is correct
25 Correct 47 ms 6616 KB Output is correct
26 Correct 45 ms 6492 KB Output is correct
27 Correct 52 ms 8408 KB Output is correct
28 Correct 51 ms 6488 KB Output is correct
29 Correct 50 ms 5720 KB Output is correct
30 Correct 51 ms 8280 KB Output is correct
31 Correct 48 ms 6360 KB Output is correct
32 Correct 54 ms 8072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 4960 KB Output is correct
2 Correct 27 ms 4960 KB Output is correct
3 Correct 26 ms 4960 KB Output is correct
4 Correct 28 ms 5080 KB Output is correct
5 Correct 28 ms 4960 KB Output is correct
6 Correct 26 ms 4952 KB Output is correct
7 Correct 29 ms 4960 KB Output is correct
8 Correct 30 ms 4960 KB Output is correct
9 Correct 26 ms 4960 KB Output is correct
10 Correct 26 ms 4960 KB Output is correct
11 Correct 26 ms 4960 KB Output is correct
12 Correct 26 ms 4960 KB Output is correct
13 Correct 31 ms 4960 KB Output is correct
14 Correct 37 ms 5336 KB Output is correct
15 Correct 52 ms 7856 KB Output is correct
16 Correct 32 ms 5080 KB Output is correct
17 Correct 47 ms 6488 KB Output is correct
18 Correct 43 ms 5976 KB Output is correct
19 Correct 46 ms 5976 KB Output is correct
20 Correct 43 ms 5976 KB Output is correct
21 Correct 43 ms 5976 KB Output is correct
22 Correct 43 ms 5976 KB Output is correct
23 Correct 48 ms 5976 KB Output is correct
24 Correct 43 ms 5976 KB Output is correct
25 Correct 47 ms 6616 KB Output is correct
26 Correct 45 ms 6492 KB Output is correct
27 Correct 52 ms 8408 KB Output is correct
28 Correct 51 ms 6488 KB Output is correct
29 Correct 50 ms 5720 KB Output is correct
30 Correct 51 ms 8280 KB Output is correct
31 Correct 48 ms 6360 KB Output is correct
32 Correct 54 ms 8072 KB Output is correct
33 Correct 912 ms 44932 KB Output is correct
34 Correct 974 ms 47784 KB Output is correct
35 Correct 928 ms 39404 KB Output is correct
36 Correct 970 ms 50112 KB Output is correct
37 Execution timed out 1043 ms 55580 KB Time limit exceeded
38 Halted 0 ms 0 KB -