結果

問題 No.1199 お菓子配り-2
ユーザー brthyyjpbrthyyjp
提出日時 2020-08-28 22:35:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 1,000 ms
コード長 423 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 85,184 KB
最終ジャッジ日時 2024-04-26 15:02:23
合計ジャッジ時間 9,386 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,096 KB
testcase_01 AC 34 ms
51,968 KB
testcase_02 AC 35 ms
51,968 KB
testcase_03 AC 81 ms
76,416 KB
testcase_04 AC 129 ms
81,208 KB
testcase_05 AC 45 ms
62,720 KB
testcase_06 AC 44 ms
65,792 KB
testcase_07 AC 84 ms
77,312 KB
testcase_08 AC 97 ms
78,372 KB
testcase_09 AC 76 ms
76,632 KB
testcase_10 AC 50 ms
72,960 KB
testcase_11 AC 74 ms
76,800 KB
testcase_12 AC 70 ms
76,376 KB
testcase_13 AC 51 ms
73,344 KB
testcase_14 AC 50 ms
71,168 KB
testcase_15 AC 49 ms
68,736 KB
testcase_16 AC 93 ms
78,496 KB
testcase_17 AC 73 ms
76,764 KB
testcase_18 AC 101 ms
78,592 KB
testcase_19 AC 63 ms
75,816 KB
testcase_20 AC 137 ms
81,664 KB
testcase_21 AC 113 ms
79,584 KB
testcase_22 AC 83 ms
77,056 KB
testcase_23 AC 93 ms
77,924 KB
testcase_24 AC 107 ms
79,744 KB
testcase_25 AC 54 ms
75,776 KB
testcase_26 AC 111 ms
80,040 KB
testcase_27 AC 94 ms
78,080 KB
testcase_28 AC 159 ms
84,864 KB
testcase_29 AC 156 ms
84,864 KB
testcase_30 AC 157 ms
85,052 KB
testcase_31 AC 157 ms
84,736 KB
testcase_32 AC 157 ms
84,992 KB
testcase_33 AC 161 ms
84,608 KB
testcase_34 AC 163 ms
85,184 KB
testcase_35 AC 160 ms
84,864 KB
testcase_36 AC 162 ms
84,608 KB
testcase_37 AC 163 ms
84,480 KB
testcase_38 AC 165 ms
84,688 KB
testcase_39 AC 166 ms
84,864 KB
testcase_40 AC 166 ms
84,992 KB
testcase_41 AC 169 ms
84,552 KB
testcase_42 AC 156 ms
84,840 KB
testcase_43 AC 168 ms
84,736 KB
testcase_44 AC 155 ms
84,992 KB
testcase_45 AC 161 ms
84,564 KB
testcase_46 AC 158 ms
84,736 KB
testcase_47 AC 161 ms
84,996 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