Submission #549351

# Submission time Handle Problem Language Result Execution time Memory
549351 2022-04-15T16:34:17 Z beaconmc Snowball (JOI21_ho_t2) PyPy 3
0 / 100
184 ms 26568 KB
from bisect import *
n,q = map(int, input().split())
lis = list(map(int, input().split()))

diffs = []
for i in range(n-1):
    diffs.append(abs(lis[i] - lis[i+1]))
ans = [0 for i in range(n)]
queries = []
for i in range(q):
    queries.append(int(input()))


states = [[0,0,0]]

cur = [0,0,0]
pos = 0
for i in range(q):
    pos += queries[i]
    sus = False
    if pos<0 and cur[1]<abs(pos):
        sus = True
        cur[1] = abs(pos)
    elif pos>0 and cur[2] < pos:
        sus = True
        cur[2] = pos

    if sus:
        cur[0] = cur[1] + cur[2]
        states.append(list(cur))

states.sort()

for i in range(n-1):
    sus = bisect(states, [diffs[i]])
    if sus==1:
        ans[i+1] += states[1][1]
        ans[i] += states[1][2]
    elif sus==len(states):
        ans[i+1] += states[-1][1]
        ans[i] += states[-1][2]
    else:
        if states[sus-1][1] == states[sus][1]:
            ans[i+1] += states[sus][1]
            ans[i] += diffs[i] - states[sus][1]
        else:
            ans[i] += states[sus][2]
            ans[i+1] += diffs[i] - states[sus][2]

ans[0] += states[-1][1]
ans[-1] += states[-1][2]

for i in ans:
    print(i)
        
# Verdict Execution time Memory Grader output
1 Correct 97 ms 22056 KB Output is correct
2 Correct 106 ms 22404 KB Output is correct
3 Correct 98 ms 22620 KB Output is correct
4 Correct 135 ms 26116 KB Output is correct
5 Correct 165 ms 26568 KB Output is correct
6 Correct 142 ms 26536 KB Output is correct
7 Correct 138 ms 26448 KB Output is correct
8 Correct 142 ms 26544 KB Output is correct
9 Correct 184 ms 26448 KB Output is correct
10 Correct 147 ms 26244 KB Output is correct
11 Correct 114 ms 25148 KB Output is correct
12 Correct 35 ms 18196 KB Output is correct
13 Correct 36 ms 18252 KB Output is correct
14 Incorrect 52 ms 18788 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 97 ms 22056 KB Output is correct
2 Correct 106 ms 22404 KB Output is correct
3 Correct 98 ms 22620 KB Output is correct
4 Correct 135 ms 26116 KB Output is correct
5 Correct 165 ms 26568 KB Output is correct
6 Correct 142 ms 26536 KB Output is correct
7 Correct 138 ms 26448 KB Output is correct
8 Correct 142 ms 26544 KB Output is correct
9 Correct 184 ms 26448 KB Output is correct
10 Correct 147 ms 26244 KB Output is correct
11 Correct 114 ms 25148 KB Output is correct
12 Correct 35 ms 18196 KB Output is correct
13 Correct 36 ms 18252 KB Output is correct
14 Incorrect 52 ms 18788 KB Output isn't correct
15 Halted 0 ms 0 KB -