結果

問題 No.1375 Divide and Update
ユーザー tempura_pptempura_pp
提出日時 2019-03-24 03:13:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 565 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 34,608 KB
最終ジャッジ日時 2024-04-10 06:48:35
合計ジャッジ時間 8,070 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 29 ms
10,752 KB
testcase_05 AC 28 ms
10,752 KB
testcase_06 AC 28 ms
10,752 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 30 ms
10,752 KB
testcase_09 AC 29 ms
10,752 KB
testcase_10 AC 502 ms
30,132 KB
testcase_11 AC 467 ms
32,172 KB
testcase_12 AC 262 ms
20,400 KB
testcase_13 AC 224 ms
18,708 KB
testcase_14 AC 560 ms
32,940 KB
testcase_15 AC 565 ms
33,072 KB
testcase_16 AC 560 ms
32,940 KB
testcase_17 AC 551 ms
32,940 KB
testcase_18 AC 561 ms
33,424 KB
testcase_19 AC 562 ms
33,304 KB
testcase_20 AC 533 ms
34,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve() :
    n,x,y=map(int,input().split())
    a = list(map(int, input().split()))
    inf = 1000000007
    dp1 = [-inf]*(n+1)
    dp2=[-inf]*(n+1)
    cur = -inf
    for i in range(n) : 
        cur = max(x-a[i], x-a[i]+cur)
        dp1[i+1] = max(dp1[i],cur)
    cur=-inf
    for i in range(n-1,-1,-1) :
        cur = max(y-a[i], y-a[i]+cur)
        dp2[i] = max(dp2[i+1],cur)
    sum = 0
    for i in a : sum+=i
    for i in range(n-2) :
        print(sum+dp1[i+1]+dp2[i+2])
solve()
0