結果

問題 No.1199 お菓子配り-2
ユーザー NatsubiSoganNatsubiSogan
提出日時 2020-08-28 22:25:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 387 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 18,944 KB
最終ジャッジ日時 2024-04-26 15:01:35
合計ジャッジ時間 37,054 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 TLE -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
n, m = map(int, input().split())
a = [sum(list(map(int, input().split()))) for i in range(n)]
dp = [[0] * n for i in range(n)]
dp[0][0] = a[0]
for i in range(n):
    for j in range(n):
        if not (i == 0 and j == 0):
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1] + a[j]) if j % 2 else max(dp[i - 1][j], dp[i][j - 1] - a[j])
print(max(dp[-1]))
0