Submission #635013

# Submission time Handle Problem Language Result Execution time Memory
635013 2022-08-25T10:10:19 Z karolb2011 Snowball (JOI21_ho_t2) PyPy 3
100 / 100
1193 ms 69040 KB
import sys
input=sys.stdin.readline
n,q=list(map(int,input().split()))
x=list(map(int,input().split()))
y=[]
for i in range(n-1):
    y.append([x[i+1]-x[i],i])
wc=0
wm=0
ws=0
y.sort(reverse=True)
L=[0 for i in range(n)]
R=[0 for i in range(n)]
for i in range(q):
    z=int(input())
    wc+=z
    wm=max(wc,wm)   
    ws=min(wc,ws)
    L[0]=-ws
    R[n-1]=wm
    while len(y) and wm-ws>=y[-1][0]:
        c,i=y.pop()
        if z<0:
            L[i+1]=min(-ws,c-wm)
            R[i]=wm
        else:
            R[i]=min(wm,c+ws)
            L[i+1]=-ws
for c,i in y:
    L[i+1]=-ws
    R[i]=wm
for i in range(n):
    print(R[i]+L[i])
# Verdict Execution time Memory Grader output
1 Correct 48 ms 19392 KB Output is correct
2 Correct 55 ms 19368 KB Output is correct
3 Correct 67 ms 19520 KB Output is correct
4 Correct 87 ms 22752 KB Output is correct
5 Correct 92 ms 22952 KB Output is correct
6 Correct 87 ms 23684 KB Output is correct
7 Correct 88 ms 23048 KB Output is correct
8 Correct 91 ms 23148 KB Output is correct
9 Correct 109 ms 23396 KB Output is correct
10 Correct 88 ms 22864 KB Output is correct
11 Correct 80 ms 22632 KB Output is correct
12 Correct 35 ms 18148 KB Output is correct
13 Correct 35 ms 18200 KB Output is correct
14 Correct 38 ms 18224 KB Output is correct
15 Correct 94 ms 23632 KB Output is correct
16 Correct 94 ms 23028 KB Output is correct
17 Correct 88 ms 23848 KB Output is correct
18 Correct 34 ms 18220 KB Output is correct
19 Correct 76 ms 22600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 19392 KB Output is correct
2 Correct 55 ms 19368 KB Output is correct
3 Correct 67 ms 19520 KB Output is correct
4 Correct 87 ms 22752 KB Output is correct
5 Correct 92 ms 22952 KB Output is correct
6 Correct 87 ms 23684 KB Output is correct
7 Correct 88 ms 23048 KB Output is correct
8 Correct 91 ms 23148 KB Output is correct
9 Correct 109 ms 23396 KB Output is correct
10 Correct 88 ms 22864 KB Output is correct
11 Correct 80 ms 22632 KB Output is correct
12 Correct 35 ms 18148 KB Output is correct
13 Correct 35 ms 18200 KB Output is correct
14 Correct 38 ms 18224 KB Output is correct
15 Correct 94 ms 23632 KB Output is correct
16 Correct 94 ms 23028 KB Output is correct
17 Correct 88 ms 23848 KB Output is correct
18 Correct 34 ms 18220 KB Output is correct
19 Correct 76 ms 22600 KB Output is correct
20 Correct 117 ms 22328 KB Output is correct
21 Correct 139 ms 22992 KB Output is correct
22 Correct 127 ms 22704 KB Output is correct
23 Correct 134 ms 25384 KB Output is correct
24 Correct 201 ms 27848 KB Output is correct
25 Correct 1048 ms 59528 KB Output is correct
26 Correct 1053 ms 59588 KB Output is correct
27 Correct 1112 ms 59252 KB Output is correct
28 Correct 1062 ms 58852 KB Output is correct
29 Correct 1012 ms 58640 KB Output is correct
30 Correct 928 ms 58044 KB Output is correct
31 Correct 675 ms 58120 KB Output is correct
32 Correct 342 ms 57384 KB Output is correct
33 Correct 190 ms 26760 KB Output is correct
34 Correct 1079 ms 59964 KB Output is correct
35 Correct 1166 ms 59700 KB Output is correct
36 Correct 1193 ms 59708 KB Output is correct
37 Correct 1155 ms 58548 KB Output is correct
38 Correct 1133 ms 59184 KB Output is correct
39 Correct 944 ms 59548 KB Output is correct
40 Correct 663 ms 58600 KB Output is correct
41 Correct 92 ms 22500 KB Output is correct
42 Correct 1064 ms 69040 KB Output is correct
43 Correct 334 ms 60720 KB Output is correct
44 Correct 96 ms 22428 KB Output is correct
45 Correct 1074 ms 65976 KB Output is correct
46 Correct 505 ms 60468 KB Output is correct
47 Correct 492 ms 61000 KB Output is correct
48 Correct 491 ms 60728 KB Output is correct