結果

問題 No.1199 お菓子配り-2
ユーザー neterukunneterukun
提出日時 2020-08-28 21:35:05
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 340 ms / 1,000 ms
コード長 570 bytes
コンパイル時間 1,252 ms
コンパイル使用メモリ 86,624 KB
実行使用メモリ 112,600 KB
最終ジャッジ日時 2023-08-08 22:17:18
合計ジャッジ時間 15,678 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,372 KB
testcase_01 AC 72 ms
71,056 KB
testcase_02 AC 70 ms
71,420 KB
testcase_03 AC 175 ms
86,296 KB
testcase_04 AC 278 ms
109,856 KB
testcase_05 AC 78 ms
75,996 KB
testcase_06 AC 97 ms
77,540 KB
testcase_07 AC 159 ms
82,008 KB
testcase_08 AC 186 ms
87,220 KB
testcase_09 AC 145 ms
79,832 KB
testcase_10 AC 112 ms
78,308 KB
testcase_11 AC 139 ms
80,828 KB
testcase_12 AC 131 ms
79,988 KB
testcase_13 AC 106 ms
77,448 KB
testcase_14 AC 114 ms
78,084 KB
testcase_15 AC 110 ms
77,804 KB
testcase_16 AC 174 ms
82,876 KB
testcase_17 AC 157 ms
82,100 KB
testcase_18 AC 249 ms
100,656 KB
testcase_19 AC 144 ms
80,808 KB
testcase_20 AC 282 ms
100,740 KB
testcase_21 AC 274 ms
107,416 KB
testcase_22 AC 227 ms
98,024 KB
testcase_23 AC 236 ms
100,088 KB
testcase_24 AC 265 ms
107,860 KB
testcase_25 AC 114 ms
77,996 KB
testcase_26 AC 209 ms
87,048 KB
testcase_27 AC 192 ms
87,244 KB
testcase_28 AC 336 ms
111,572 KB
testcase_29 AC 335 ms
112,028 KB
testcase_30 AC 331 ms
111,780 KB
testcase_31 AC 340 ms
110,988 KB
testcase_32 AC 336 ms
111,688 KB
testcase_33 AC 339 ms
110,900 KB
testcase_34 AC 335 ms
111,836 KB
testcase_35 AC 336 ms
111,112 KB
testcase_36 AC 335 ms
111,136 KB
testcase_37 AC 334 ms
111,852 KB
testcase_38 AC 336 ms
111,516 KB
testcase_39 AC 338 ms
111,368 KB
testcase_40 AC 333 ms
112,404 KB
testcase_41 AC 328 ms
112,528 KB
testcase_42 AC 332 ms
112,600 KB
testcase_43 AC 336 ms
112,384 KB
testcase_44 AC 334 ms
112,448 KB
testcase_45 AC 340 ms
112,520 KB
testcase_46 AC 334 ms
111,732 KB
testcase_47 AC 338 ms
112,356 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