結果

問題 No.1375 Divide and Update
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-25 18:10:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 744 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 140,144 KB
最終ジャッジ日時 2023-08-22 13:17:34
合計ジャッジ時間 8,025 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,168 KB
testcase_01 AC 79 ms
71,496 KB
testcase_02 AC 79 ms
71,224 KB
testcase_03 AC 77 ms
71,228 KB
testcase_04 AC 78 ms
71,328 KB
testcase_05 AC 79 ms
71,328 KB
testcase_06 AC 78 ms
71,528 KB
testcase_07 AC 77 ms
71,328 KB
testcase_08 AC 78 ms
71,292 KB
testcase_09 AC 78 ms
71,184 KB
testcase_10 AC 242 ms
135,512 KB
testcase_11 AC 206 ms
133,172 KB
testcase_12 AC 169 ms
95,564 KB
testcase_13 AC 158 ms
93,408 KB
testcase_14 AC 245 ms
130,300 KB
testcase_15 AC 254 ms
130,584 KB
testcase_16 AC 257 ms
119,540 KB
testcase_17 AC 259 ms
119,560 KB
testcase_18 AC 251 ms
121,376 KB
testcase_19 AC 254 ms
121,388 KB
testcase_20 AC 214 ms
140,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x, y = map(int, input().split())
A = list(map(int, input().split()))

s = sum(A)

from itertools import accumulate
INF = 10**18
C = [0]+A
C = list(accumulate(C))
L = [-INF]
import heapq
q = []
heapq.heapify(q)
heapq.heappush(q, x*0-C[0])
for i in range(1, n+1):
    temp = (x*i-C[i])-q[0]
    L.append(temp)
    heapq.heappush(q, x*i-C[i])
#print(L)
R = [-INF]
q = []
heapq.heapify(q)
heapq.heappush(q, -(y*n-C[n]))
for i in reversed(range(n)):
    temp = -q[0]-(y*i-C[i])
    R.append(temp)
    heapq.heappush(q, -(y*i-C[i]))
R.reverse()
#print(R)
for i in range(1, n+1):
    L[i] = max(L[i-1], L[i])
for i in range(n-1, -1, -1):
    R[i] = max(R[i+1], R[i])
#print(L)
#print(R)
for i in range(2, n):
    ans = s+L[i-1]+R[i]
    print(ans)
0