結果

問題 No.1375 Divide and Update
ユーザー H3PO4
提出日時 2022-04-21 10:39:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 213 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 81,648 KB
実行使用メモリ 143,020 KB
最終ジャッジ日時 2024-06-22 09:46:18
合計ジャッジ時間 5,522 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

N, X, Y = map(int, input().split())
A = tuple(map(int, input().split()))

S = sum(A)


def solve_left(B, Z):
    acc = 0
    res = -float("INF")
    max_val = 0
    for b in B[:-2]:
        acc += b - Z
        if res < max_val - acc:
            res = max_val - acc
        if max_val < acc:
            max_val = acc
        yield res


l_res = tuple(solve_left(A, X))
r_res = tuple(solve_left(A[::-1], Y))[::-1]
for l, r in zip(l_res, r_res):
    print(S + l + r)
0