結果

問題 No.1199 お菓子配り-2
ユーザー tobusakanatobusakana
提出日時 2022-11-26 13:25:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 174 ms / 1,000 ms
コード長 552 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-04-10 14:40:51
合計ジャッジ時間 12,697 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,096 KB
testcase_01 AC 36 ms
51,840 KB
testcase_02 AC 36 ms
51,968 KB
testcase_03 AC 89 ms
75,008 KB
testcase_04 AC 128 ms
76,288 KB
testcase_05 AC 45 ms
62,464 KB
testcase_06 AC 49 ms
65,920 KB
testcase_07 AC 90 ms
75,776 KB
testcase_08 AC 102 ms
75,520 KB
testcase_09 AC 84 ms
75,392 KB
testcase_10 AC 60 ms
72,448 KB
testcase_11 AC 76 ms
75,392 KB
testcase_12 AC 76 ms
75,264 KB
testcase_13 AC 59 ms
73,600 KB
testcase_14 AC 57 ms
71,168 KB
testcase_15 AC 54 ms
68,224 KB
testcase_16 AC 99 ms
75,520 KB
testcase_17 AC 81 ms
75,008 KB
testcase_18 AC 113 ms
75,776 KB
testcase_19 AC 74 ms
75,264 KB
testcase_20 AC 139 ms
75,776 KB
testcase_21 AC 112 ms
75,904 KB
testcase_22 AC 91 ms
75,264 KB
testcase_23 AC 101 ms
75,776 KB
testcase_24 AC 114 ms
75,776 KB
testcase_25 AC 64 ms
75,392 KB
testcase_26 AC 111 ms
75,264 KB
testcase_27 AC 103 ms
75,136 KB
testcase_28 AC 163 ms
76,544 KB
testcase_29 AC 163 ms
76,416 KB
testcase_30 AC 163 ms
76,160 KB
testcase_31 AC 164 ms
76,160 KB
testcase_32 AC 163 ms
76,288 KB
testcase_33 AC 164 ms
76,032 KB
testcase_34 AC 160 ms
76,288 KB
testcase_35 AC 162 ms
76,032 KB
testcase_36 AC 166 ms
76,416 KB
testcase_37 AC 162 ms
76,032 KB
testcase_38 AC 165 ms
75,776 KB
testcase_39 AC 166 ms
76,288 KB
testcase_40 AC 164 ms
76,160 KB
testcase_41 AC 165 ms
76,160 KB
testcase_42 AC 174 ms
75,904 KB
testcase_43 AC 166 ms
75,904 KB
testcase_44 AC 173 ms
76,160 KB
testcase_45 AC 171 ms
76,672 KB
testcase_46 AC 166 ms
75,904 KB
testcase_47 AC 172 ms
76,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
INF = 1 << 60
dp = [-INF] * 2 # 次に食べるのが1:増加の場合,0:減少 の場合の最大幸福度
dp[1] = 0

for i in range(N):
  val = sum(list(map(int,input().split())))
  new_dp = [-INF] * 2
  # 次が増加の場合の食べる場合と食べない場合
  # 食べるとdp[1]である
  new_dp[0] = max(new_dp[0], dp[1] + val)
  new_dp[1] = max(new_dp[1], dp[1])
  
  # 次が減少の場合
  new_dp[1] = max(new_dp[1], dp[0] - val)
  new_dp[0] = max(new_dp[0], dp[0])
  
  dp = new_dp
  
print(max(dp))
0