結果

問題 No.1199 お菓子配り-2
ユーザー toyuzukotoyuzuko
提出日時 2020-08-30 10:59:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 205 ms / 1,000 ms
コード長 474 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 84,736 KB
最終ジャッジ日時 2024-04-27 01:45:22
合計ジャッジ時間 10,283 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,744 KB
testcase_01 AC 36 ms
52,884 KB
testcase_02 AC 37 ms
52,972 KB
testcase_03 AC 96 ms
76,068 KB
testcase_04 AC 153 ms
82,772 KB
testcase_05 AC 41 ms
62,340 KB
testcase_06 AC 54 ms
69,700 KB
testcase_07 AC 100 ms
77,784 KB
testcase_08 AC 103 ms
75,908 KB
testcase_09 AC 84 ms
76,292 KB
testcase_10 AC 65 ms
75,684 KB
testcase_11 AC 83 ms
76,928 KB
testcase_12 AC 76 ms
76,184 KB
testcase_13 AC 62 ms
75,744 KB
testcase_14 AC 60 ms
74,156 KB
testcase_15 AC 58 ms
72,976 KB
testcase_16 AC 105 ms
75,996 KB
testcase_17 AC 89 ms
77,608 KB
testcase_18 AC 136 ms
82,176 KB
testcase_19 AC 82 ms
75,932 KB
testcase_20 AC 160 ms
76,440 KB
testcase_21 AC 140 ms
76,060 KB
testcase_22 AC 115 ms
76,216 KB
testcase_23 AC 126 ms
76,108 KB
testcase_24 AC 139 ms
77,468 KB
testcase_25 AC 63 ms
75,940 KB
testcase_26 AC 129 ms
76,212 KB
testcase_27 AC 109 ms
76,176 KB
testcase_28 AC 197 ms
84,524 KB
testcase_29 AC 192 ms
84,244 KB
testcase_30 AC 198 ms
84,140 KB
testcase_31 AC 197 ms
84,372 KB
testcase_32 AC 200 ms
84,448 KB
testcase_33 AC 195 ms
84,632 KB
testcase_34 AC 198 ms
84,336 KB
testcase_35 AC 199 ms
84,520 KB
testcase_36 AC 198 ms
84,736 KB
testcase_37 AC 194 ms
84,488 KB
testcase_38 AC 196 ms
84,564 KB
testcase_39 AC 205 ms
84,064 KB
testcase_40 AC 195 ms
84,580 KB
testcase_41 AC 189 ms
84,228 KB
testcase_42 AC 194 ms
84,672 KB
testcase_43 AC 195 ms
84,616 KB
testcase_44 AC 195 ms
84,520 KB
testcase_45 AC 196 ms
84,248 KB
testcase_46 AC 196 ms
84,472 KB
testcase_47 AC 192 ms
84,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 10**18

N, M = map(int, input().split())
A = [sum(map(int, input().split())) for _ in range(N)]

dp = [[-INF for j in range(N + 1)] for i in range(N + 1)]

for i in range(N + 1):
    dp[i][0] = 0

for i in range(1, N + 1):
    for j in range(1, N + 1):
        if j % 2 == 0:
            dp[i][j] = max(dp[i][j], dp[i - 1][j], dp[i - 1][j - 1] - A[i - 1])
        else:
            dp[i][j] = max(dp[i][j], dp[i - 1][j], dp[i - 1][j - 1] + A[i - 1])

print(max(dp[N]))
0