結果

問題 No.1199 お菓子配り-2
ユーザー marroncastlemarroncastle
提出日時 2020-08-28 22:22:26
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 338 ms / 1,000 ms
コード長 327 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 10,980 KB
実行使用メモリ 30,032 KB
最終ジャッジ日時 2023-08-08 22:49:24
合計ジャッジ時間 15,690 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
29,652 KB
testcase_01 AC 121 ms
29,480 KB
testcase_02 AC 120 ms
29,568 KB
testcase_03 AC 179 ms
29,836 KB
testcase_04 AC 252 ms
29,884 KB
testcase_05 AC 120 ms
29,720 KB
testcase_06 AC 128 ms
29,556 KB
testcase_07 AC 182 ms
29,696 KB
testcase_08 AC 208 ms
29,904 KB
testcase_09 AC 173 ms
29,692 KB
testcase_10 AC 133 ms
29,636 KB
testcase_11 AC 159 ms
29,632 KB
testcase_12 AC 161 ms
29,716 KB
testcase_13 AC 137 ms
29,804 KB
testcase_14 AC 135 ms
29,684 KB
testcase_15 AC 131 ms
29,604 KB
testcase_16 AC 205 ms
29,712 KB
testcase_17 AC 167 ms
29,892 KB
testcase_18 AC 210 ms
29,716 KB
testcase_19 AC 140 ms
29,788 KB
testcase_20 AC 279 ms
29,880 KB
testcase_21 AC 217 ms
29,876 KB
testcase_22 AC 179 ms
29,856 KB
testcase_23 AC 198 ms
29,664 KB
testcase_24 AC 229 ms
29,864 KB
testcase_25 AC 137 ms
29,708 KB
testcase_26 AC 236 ms
29,888 KB
testcase_27 AC 216 ms
29,884 KB
testcase_28 AC 335 ms
29,924 KB
testcase_29 AC 330 ms
29,812 KB
testcase_30 AC 334 ms
30,000 KB
testcase_31 AC 336 ms
29,944 KB
testcase_32 AC 337 ms
30,032 KB
testcase_33 AC 338 ms
29,896 KB
testcase_34 AC 327 ms
29,996 KB
testcase_35 AC 337 ms
29,972 KB
testcase_36 AC 338 ms
29,900 KB
testcase_37 AC 336 ms
29,764 KB
testcase_38 AC 332 ms
29,828 KB
testcase_39 AC 328 ms
29,972 KB
testcase_40 AC 320 ms
29,876 KB
testcase_41 AC 325 ms
29,956 KB
testcase_42 AC 329 ms
29,816 KB
testcase_43 AC 330 ms
29,936 KB
testcase_44 AC 321 ms
29,828 KB
testcase_45 AC 330 ms
29,984 KB
testcase_46 AC 324 ms
29,916 KB
testcase_47 AC 329 ms
29,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
N, M = map(int, input().split())
A = [sum(map(int, input().split())) for _ in range(N)]
dp1 = A[:]
dp2 = [0]*N
if N>1:
  dp1[1] = max(dp1[1],dp1[0])
  dp2[1] = dp1[0]-A[1]
for i in range(2,N):
  dp1[i] = max([dp1[i],dp1[i-1],dp2[i-1]+A[i]])
  dp2[i] = max(dp1[i-1]-A[i],dp2[i-1])
print(max(dp1[-1],dp2[-1]))
0