結果

問題 No.1375 Divide and Update
ユーザー 👑 rin204rin204
提出日時 2022-04-16 16:30:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 531 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 86,780 KB
実行使用メモリ 114,336 KB
最終ジャッジ日時 2023-08-26 19:14:22
合計ジャッジ時間 5,044 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,052 KB
testcase_01 AC 65 ms
71,084 KB
testcase_02 AC 65 ms
71,108 KB
testcase_03 AC 67 ms
70,924 KB
testcase_04 AC 69 ms
71,124 KB
testcase_05 AC 69 ms
71,084 KB
testcase_06 AC 69 ms
71,052 KB
testcase_07 AC 67 ms
71,272 KB
testcase_08 AC 67 ms
71,224 KB
testcase_09 AC 69 ms
71,232 KB
testcase_10 AC 173 ms
105,740 KB
testcase_11 AC 148 ms
103,864 KB
testcase_12 AC 116 ms
93,556 KB
testcase_13 AC 115 ms
91,040 KB
testcase_14 AC 162 ms
110,108 KB
testcase_15 AC 161 ms
109,984 KB
testcase_16 AC 165 ms
110,036 KB
testcase_17 AC 166 ms
110,004 KB
testcase_18 AC 148 ms
111,728 KB
testcase_19 AC 147 ms
111,804 KB
testcase_20 AC 141 ms
114,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

min_ = 0
tmp = 0
L = [0] * (n - 2)
for i, a in enumerate(A[:n-2]):
    tmp += x - a
    L[i] = tmp - min_
    if i != 0 and L[i - 1] > L[i]:
        L[i] = L[i - 1]
    min_ = min(tmp, min_)

min_ = 0
tmp = 0
R = [0] * (n - 2)
for i, a in enumerate(A[2:][::-1]):
    tmp += y - a
    R[i] = tmp - min_
    if i != 0 and R[i - 1] > R[i]:
        R[i] = R[i - 1]
    min_ = min(tmp, min_)

R = R[::-1]
for l, r in zip(L, R):
    print(tot + l + r)
0