結果

問題 No.1375 Divide and Update
ユーザー tktk_snsntktk_snsn
提出日時 2021-02-05 22:18:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 692 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 175,912 KB
最終ジャッジ日時 2023-09-15 08:34:53
合計ジャッジ時間 5,484 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,536 KB
testcase_01 AC 73 ms
71,452 KB
testcase_02 AC 72 ms
71,448 KB
testcase_03 WA -
testcase_04 AC 74 ms
71,524 KB
testcase_05 WA -
testcase_06 AC 73 ms
71,452 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 193 ms
135,280 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 201 ms
139,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
N, X, Y = map(int, input().split())
A = list(map(int, input().split()))

sumA = list(accumulate(A, initial=0))

L = [X * i - s for i, s in enumerate(sumA)]
R = [Y * i - s for i, s in enumerate(sumA)]

cntL = [L[1] - L[0]]
minL = min(L[0], L[1])
maxL = max(L[0], L[1])
for x in L[2:]:
    minL = min(minL, x)
    maxL = max(maxL, x)
    cntL.append(maxL - minL)

cntR = [R[N] - R[N-1]]
minR = min(R[N], R[N-1])
maxR = max(R[N], R[N-1])
for x in R[:-2][::-1]:
    minR = min(minR, x)
    maxR = max(maxR, x)
    cntR.append(maxR - minR)
cntR.reverse()

X = sum(A)
for i in range(N - 2):
    print(X + cntL[i] + cntR[i+2])
0