結果

問題 No.1199 お菓子配り-2
ユーザー neterukunneterukun
提出日時 2020-08-28 21:35:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 316 ms / 1,000 ms
コード長 570 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 82,728 KB
実行使用メモリ 112,584 KB
最終ジャッジ日時 2024-04-26 14:26:11
合計ジャッジ時間 14,183 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,620 KB
testcase_01 AC 36 ms
52,212 KB
testcase_02 AC 36 ms
52,708 KB
testcase_03 AC 142 ms
86,936 KB
testcase_04 AC 235 ms
100,912 KB
testcase_05 AC 44 ms
63,632 KB
testcase_06 AC 64 ms
73,840 KB
testcase_07 AC 133 ms
81,224 KB
testcase_08 AC 159 ms
87,552 KB
testcase_09 AC 115 ms
79,900 KB
testcase_10 AC 82 ms
77,072 KB
testcase_11 AC 109 ms
80,332 KB
testcase_12 AC 96 ms
77,912 KB
testcase_13 AC 76 ms
76,452 KB
testcase_14 AC 83 ms
76,848 KB
testcase_15 AC 79 ms
76,612 KB
testcase_16 AC 143 ms
82,488 KB
testcase_17 AC 125 ms
81,880 KB
testcase_18 AC 228 ms
100,740 KB
testcase_19 AC 108 ms
79,952 KB
testcase_20 AC 258 ms
100,412 KB
testcase_21 AC 248 ms
107,448 KB
testcase_22 AC 200 ms
98,196 KB
testcase_23 AC 208 ms
100,300 KB
testcase_24 AC 217 ms
98,792 KB
testcase_25 AC 83 ms
77,144 KB
testcase_26 AC 182 ms
87,640 KB
testcase_27 AC 147 ms
81,844 KB
testcase_28 AC 316 ms
112,012 KB
testcase_29 AC 289 ms
112,204 KB
testcase_30 AC 294 ms
112,136 KB
testcase_31 AC 299 ms
111,300 KB
testcase_32 AC 288 ms
111,960 KB
testcase_33 AC 297 ms
111,256 KB
testcase_34 AC 295 ms
112,472 KB
testcase_35 AC 297 ms
111,820 KB
testcase_36 AC 301 ms
111,784 KB
testcase_37 AC 298 ms
112,152 KB
testcase_38 AC 300 ms
112,248 KB
testcase_39 AC 301 ms
111,460 KB
testcase_40 AC 298 ms
111,956 KB
testcase_41 AC 294 ms
112,088 KB
testcase_42 AC 295 ms
112,448 KB
testcase_43 AC 300 ms
112,080 KB
testcase_44 AC 294 ms
112,584 KB
testcase_45 AC 300 ms
112,520 KB
testcase_46 AC 294 ms
112,140 KB
testcase_47 AC 292 ms
112,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
INF = 10 ** 22


b = [sum(a[i]) for i in range(n)]


dp = [[-INF] * (n + 1) for i in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    val = b[i]
    for j in range(n + 1):
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])
        if j + 1 > n:
            continue
        if (j + 1) % 2 == 1:
            dp[i + 1][j + 1] = max(dp[i][j] + val, dp[i + 1][j + 1])
        else:
            dp[i + 1][j + 1] = max(dp[i][j] - val, dp[i + 1][j + 1])
            

print(max(dp[-1]))
0