結果

問題 No.1375 Divide and Update
ユーザー gorugo30gorugo30
提出日時 2021-02-05 22:01:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 655 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 115,812 KB
最終ジャッジ日時 2023-09-15 08:11:22
合計ジャッジ時間 5,189 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,520 KB
testcase_01 AC 70 ms
71,156 KB
testcase_02 AC 71 ms
71,660 KB
testcase_03 AC 71 ms
71,532 KB
testcase_04 AC 71 ms
71,424 KB
testcase_05 AC 69 ms
71,296 KB
testcase_06 AC 69 ms
71,468 KB
testcase_07 AC 71 ms
71,320 KB
testcase_08 AC 70 ms
71,500 KB
testcase_09 AC 70 ms
71,360 KB
testcase_10 AC 169 ms
107,584 KB
testcase_11 AC 152 ms
103,344 KB
testcase_12 AC 124 ms
94,680 KB
testcase_13 AC 120 ms
91,780 KB
testcase_14 AC 176 ms
112,244 KB
testcase_15 AC 177 ms
112,012 KB
testcase_16 AC 174 ms
112,000 KB
testcase_17 AC 174 ms
112,012 KB
testcase_18 AC 178 ms
113,916 KB
testcase_19 AC 175 ms
113,632 KB
testcase_20 AC 157 ms
115,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, X, Y = map(int, input().split())
A = list(map(int, input().split()))
dpX = [0] * N
dpX[0] = X - A[0]
for i in range(1, N):
    dpX[i] = max(dpX[i - 1], 0) + X - A[i]
maxX = [dpX[0]] * N
for i in range(1, N):
    maxX[i] = max(maxX[i - 1], dpX[i])
A = A[::-1]
dpY = [0] * N
dpY[0] = Y - A[0]
for i in range(1, N):
    dpY[i] = max(dpY[i - 1], 0) + Y - A[i]
maxY = [dpY[0]] * N
for i in range(1, N):
    maxY[i] = max(maxY[i - 1], dpY[i])

A = A[::-1]
sumA = sum(A)
maxY = maxY[::-1]
for i in range(1, N - 1):
    print(sumA + maxX[i - 1] + maxY[i + 1])
0