import sys
input=sys.stdin.readline
n,q=list(map(int,input().split()))
x=list(map(int,input().split()))
wc=0
wm=0
ws=0
L=[0 for i in range(n)]
R=[0 for i in range(n)]
for i in range(q):
wc+=int(input())
wm=max(wc,wm)
ws=min(wc,ws)
for i in range(n):
if i==0:
L[i]=-ws
else:
L[i]=max(min(-ws,x[i]-x[i-1]-wm),L[i])
if i==n-1:
R[i]=wm
else:
R[i]=max(min(wm,x[i+1]-x[i]+ws),R[i])
for i in range(n):
print(R[i]+L[i])
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
58 ms |
20432 KB |
Output is correct |
2 |
Correct |
56 ms |
20420 KB |
Output is correct |
3 |
Correct |
74 ms |
20748 KB |
Output is correct |
4 |
Correct |
163 ms |
24636 KB |
Output is correct |
5 |
Correct |
168 ms |
24928 KB |
Output is correct |
6 |
Correct |
171 ms |
25208 KB |
Output is correct |
7 |
Correct |
174 ms |
24968 KB |
Output is correct |
8 |
Correct |
165 ms |
24204 KB |
Output is correct |
9 |
Correct |
171 ms |
24960 KB |
Output is correct |
10 |
Correct |
190 ms |
25184 KB |
Output is correct |
11 |
Correct |
111 ms |
23968 KB |
Output is correct |
12 |
Correct |
35 ms |
18184 KB |
Output is correct |
13 |
Correct |
36 ms |
18196 KB |
Output is correct |
14 |
Correct |
55 ms |
19224 KB |
Output is correct |
15 |
Correct |
164 ms |
25356 KB |
Output is correct |
16 |
Correct |
169 ms |
24976 KB |
Output is correct |
17 |
Correct |
166 ms |
24988 KB |
Output is correct |
18 |
Correct |
33 ms |
18220 KB |
Output is correct |
19 |
Correct |
91 ms |
22616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
58 ms |
20432 KB |
Output is correct |
2 |
Correct |
56 ms |
20420 KB |
Output is correct |
3 |
Correct |
74 ms |
20748 KB |
Output is correct |
4 |
Correct |
163 ms |
24636 KB |
Output is correct |
5 |
Correct |
168 ms |
24928 KB |
Output is correct |
6 |
Correct |
171 ms |
25208 KB |
Output is correct |
7 |
Correct |
174 ms |
24968 KB |
Output is correct |
8 |
Correct |
165 ms |
24204 KB |
Output is correct |
9 |
Correct |
171 ms |
24960 KB |
Output is correct |
10 |
Correct |
190 ms |
25184 KB |
Output is correct |
11 |
Correct |
111 ms |
23968 KB |
Output is correct |
12 |
Correct |
35 ms |
18184 KB |
Output is correct |
13 |
Correct |
36 ms |
18196 KB |
Output is correct |
14 |
Correct |
55 ms |
19224 KB |
Output is correct |
15 |
Correct |
164 ms |
25356 KB |
Output is correct |
16 |
Correct |
169 ms |
24976 KB |
Output is correct |
17 |
Correct |
166 ms |
24988 KB |
Output is correct |
18 |
Correct |
33 ms |
18220 KB |
Output is correct |
19 |
Correct |
91 ms |
22616 KB |
Output is correct |
20 |
Correct |
125 ms |
24280 KB |
Output is correct |
21 |
Correct |
181 ms |
23004 KB |
Output is correct |
22 |
Correct |
717 ms |
23500 KB |
Output is correct |
23 |
Execution timed out |
2578 ms |
23340 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |