結果

問題 No.1375 Divide and Update
ユーザー H3PO4H3PO4
提出日時 2022-04-21 10:39:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 1,301 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 145,020 KB
最終ジャッジ日時 2023-09-04 10:51:12
合計ジャッジ時間 8,395 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,352 KB
testcase_01 AC 73 ms
71,316 KB
testcase_02 AC 72 ms
71,308 KB
testcase_03 AC 73 ms
71,256 KB
testcase_04 AC 72 ms
71,280 KB
testcase_05 AC 71 ms
71,252 KB
testcase_06 AC 71 ms
71,412 KB
testcase_07 AC 72 ms
71,048 KB
testcase_08 AC 71 ms
71,500 KB
testcase_09 AC 70 ms
71,224 KB
testcase_10 AC 222 ms
135,980 KB
testcase_11 AC 192 ms
129,484 KB
testcase_12 AC 140 ms
95,584 KB
testcase_13 AC 145 ms
96,632 KB
testcase_14 AC 226 ms
144,920 KB
testcase_15 AC 224 ms
145,020 KB
testcase_16 AC 228 ms
142,044 KB
testcase_17 AC 228 ms
142,060 KB
testcase_18 AC 206 ms
141,520 KB
testcase_19 AC 204 ms
141,420 KB
testcase_20 AC 201 ms
124,992 KB
権限があれば一括ダウンロードができます

ソースコード

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