답안 #635103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
635103 2022-08-25T12:26:19 Z karolb2011 Snowball (JOI21_ho_t2) PyPy 3
100 / 100
1110 ms 55600 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)
u=[0 for i in range(n)]
for i in range(q):
    z=int(input())  
    wc+=z
    wm=max(wc,wm)   
    ws=min(wc,ws)
    while len(y) and wm-ws>=y[-1][0]:
        c,i=y.pop()
        if z<0:
            u[i+1]+=c-wm
            u[i]+=wm
        else:
            u[i]+=c+ws
            u[i+1]-=ws
while len(y):
    c,i=y.pop()
    u[i]+=wm
    u[i+1]-=ws
u[0]-=ws
u[n-1]+=wm
for c in u:
    print(c)
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 19172 KB Output is correct
2 Correct 59 ms 19212 KB Output is correct
3 Correct 56 ms 19324 KB Output is correct
4 Correct 91 ms 22768 KB Output is correct
5 Correct 96 ms 22980 KB Output is correct
6 Correct 91 ms 23124 KB Output is correct
7 Correct 83 ms 22184 KB Output is correct
8 Correct 91 ms 22984 KB Output is correct
9 Correct 89 ms 23176 KB Output is correct
10 Correct 113 ms 22912 KB Output is correct
11 Correct 94 ms 22864 KB Output is correct
12 Correct 33 ms 18188 KB Output is correct
13 Correct 33 ms 18156 KB Output is correct
14 Correct 39 ms 18272 KB Output is correct
15 Correct 102 ms 23248 KB Output is correct
16 Correct 90 ms 22824 KB Output is correct
17 Correct 96 ms 23464 KB Output is correct
18 Correct 41 ms 18220 KB Output is correct
19 Correct 77 ms 22396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 19172 KB Output is correct
2 Correct 59 ms 19212 KB Output is correct
3 Correct 56 ms 19324 KB Output is correct
4 Correct 91 ms 22768 KB Output is correct
5 Correct 96 ms 22980 KB Output is correct
6 Correct 91 ms 23124 KB Output is correct
7 Correct 83 ms 22184 KB Output is correct
8 Correct 91 ms 22984 KB Output is correct
9 Correct 89 ms 23176 KB Output is correct
10 Correct 113 ms 22912 KB Output is correct
11 Correct 94 ms 22864 KB Output is correct
12 Correct 33 ms 18188 KB Output is correct
13 Correct 33 ms 18156 KB Output is correct
14 Correct 39 ms 18272 KB Output is correct
15 Correct 102 ms 23248 KB Output is correct
16 Correct 90 ms 22824 KB Output is correct
17 Correct 96 ms 23464 KB Output is correct
18 Correct 41 ms 18220 KB Output is correct
19 Correct 77 ms 22396 KB Output is correct
20 Correct 112 ms 22316 KB Output is correct
21 Correct 117 ms 22368 KB Output is correct
22 Correct 117 ms 21764 KB Output is correct
23 Correct 132 ms 23560 KB Output is correct
24 Correct 220 ms 25752 KB Output is correct
25 Correct 1110 ms 55388 KB Output is correct
26 Correct 997 ms 55356 KB Output is correct
27 Correct 1012 ms 55372 KB Output is correct
28 Correct 1026 ms 55436 KB Output is correct
29 Correct 984 ms 54788 KB Output is correct
30 Correct 866 ms 54252 KB Output is correct
31 Correct 618 ms 54048 KB Output is correct
32 Correct 298 ms 54064 KB Output is correct
33 Correct 172 ms 26364 KB Output is correct
34 Correct 1006 ms 55032 KB Output is correct
35 Correct 994 ms 55032 KB Output is correct
36 Correct 1018 ms 55336 KB Output is correct
37 Correct 1039 ms 55120 KB Output is correct
38 Correct 1039 ms 55284 KB Output is correct
39 Correct 896 ms 54840 KB Output is correct
40 Correct 652 ms 55272 KB Output is correct
41 Correct 87 ms 19752 KB Output is correct
42 Correct 1020 ms 54088 KB Output is correct
43 Correct 331 ms 55600 KB Output is correct
44 Correct 90 ms 19844 KB Output is correct
45 Correct 1050 ms 55112 KB Output is correct
46 Correct 506 ms 55552 KB Output is correct
47 Correct 475 ms 55416 KB Output is correct
48 Correct 519 ms 55236 KB Output is correct