結果

問題 No.1199 お菓子配り-2
ユーザー brthyyjpbrthyyjp
提出日時 2020-08-28 22:35:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 216 ms / 1,000 ms
コード長 423 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 86,052 KB
最終ジャッジ日時 2023-08-08 22:51:34
合計ジャッジ時間 11,479 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
70,928 KB
testcase_01 AC 67 ms
71,260 KB
testcase_02 AC 67 ms
71,084 KB
testcase_03 AC 109 ms
77,488 KB
testcase_04 AC 165 ms
82,420 KB
testcase_05 AC 74 ms
75,664 KB
testcase_06 AC 77 ms
75,540 KB
testcase_07 AC 118 ms
78,308 KB
testcase_08 AC 135 ms
79,172 KB
testcase_09 AC 111 ms
78,352 KB
testcase_10 AC 85 ms
76,648 KB
testcase_11 AC 104 ms
77,520 KB
testcase_12 AC 102 ms
77,452 KB
testcase_13 AC 83 ms
76,652 KB
testcase_14 AC 83 ms
75,528 KB
testcase_15 AC 80 ms
75,888 KB
testcase_16 AC 129 ms
79,072 KB
testcase_17 AC 103 ms
77,680 KB
testcase_18 AC 137 ms
80,732 KB
testcase_19 AC 93 ms
76,696 KB
testcase_20 AC 175 ms
82,940 KB
testcase_21 AC 145 ms
80,456 KB
testcase_22 AC 115 ms
77,836 KB
testcase_23 AC 126 ms
78,804 KB
testcase_24 AC 143 ms
80,652 KB
testcase_25 AC 84 ms
76,740 KB
testcase_26 AC 145 ms
80,932 KB
testcase_27 AC 132 ms
79,132 KB
testcase_28 AC 208 ms
85,680 KB
testcase_29 AC 205 ms
85,772 KB
testcase_30 AC 205 ms
85,624 KB
testcase_31 AC 206 ms
85,644 KB
testcase_32 AC 203 ms
85,988 KB
testcase_33 AC 203 ms
85,800 KB
testcase_34 AC 206 ms
85,928 KB
testcase_35 AC 214 ms
85,768 KB
testcase_36 AC 216 ms
85,812 KB
testcase_37 AC 212 ms
86,052 KB
testcase_38 AC 210 ms
85,644 KB
testcase_39 AC 206 ms
85,928 KB
testcase_40 AC 208 ms
85,720 KB
testcase_41 AC 205 ms
85,776 KB
testcase_42 AC 207 ms
85,676 KB
testcase_43 AC 207 ms
85,852 KB
testcase_44 AC 210 ms
85,704 KB
testcase_45 AC 210 ms
85,824 KB
testcase_46 AC 203 ms
85,860 KB
testcase_47 AC 196 ms
85,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
S = [sum(a) for a in A]
#print(S)

INF = 10**18
# dp[i][j]: jはこれまでのカウントのmod2
dp = [[-INF]*2 for _ in range(n+1)]
dp[0][0] = 0
for i in range(n):
    dp[i+1][0] = dp[i][0]
    dp[i+1][1] = dp[i][1]
    dp[i+1][1] = max(dp[i+1][1], dp[i][0]+S[i])
    dp[i+1][0] = max(dp[i+1][0], dp[i][1]-S[i])
print(max(dp[-1]))
0