結果

問題 No.1375 Divide and Update
ユーザー KudeKude
提出日時 2021-02-05 22:32:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 133,092 KB
最終ジャッジ日時 2023-09-15 09:01:07
合計ジャッジ時間 5,695 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,436 KB
testcase_01 AC 74 ms
71,292 KB
testcase_02 AC 73 ms
71,336 KB
testcase_03 AC 72 ms
71,360 KB
testcase_04 AC 74 ms
71,340 KB
testcase_05 AC 73 ms
71,228 KB
testcase_06 AC 74 ms
71,332 KB
testcase_07 AC 73 ms
71,436 KB
testcase_08 AC 73 ms
71,316 KB
testcase_09 AC 73 ms
71,604 KB
testcase_10 AC 190 ms
124,416 KB
testcase_11 AC 169 ms
102,672 KB
testcase_12 AC 133 ms
96,728 KB
testcase_13 AC 131 ms
98,108 KB
testcase_14 AC 199 ms
131,320 KB
testcase_15 AC 202 ms
130,988 KB
testcase_16 AC 199 ms
131,228 KB
testcase_17 AC 197 ms
131,256 KB
testcase_18 AC 196 ms
133,024 KB
testcase_19 AC 197 ms
133,092 KB
testcase_20 AC 176 ms
121,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x, y = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
df = [x - a[i] for i in range(n)]
db = [y - a[i] for i in range(n)]

dp_f = []
now = 0
for x in df:
    now = max(x, x + now)
    dp_f.append(now)
dp_b = []

now = 0
for x in reversed(db):
    now = max(x, x + now)
    dp_b.append(now)
dp_b.reverse()

now = -10 ** 18
for i in range(n):
    now = max(now, dp_f[i])
    dp_f[i] = now

now = -10 ** 18
for i in range(n)[::-1]:
    now = max(now, dp_b[i])
    dp_b[i] = now

for i in range(1, n - 1):
    print(s + dp_f[i - 1] + dp_b[i + 1])
0