結果

問題 No.1199 お菓子配り-2
ユーザー donutholedonuthole
提出日時 2020-08-29 00:43:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 978 ms / 1,000 ms
コード長 1,008 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 51,712 KB
最終ジャッジ日時 2024-04-26 15:38:37
合計ジャッジ時間 31,941 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
11,264 KB
testcase_01 AC 35 ms
11,264 KB
testcase_02 AC 34 ms
11,136 KB
testcase_03 AC 324 ms
21,376 KB
testcase_04 AC 736 ms
36,992 KB
testcase_05 AC 41 ms
12,032 KB
testcase_06 AC 50 ms
12,800 KB
testcase_07 AC 247 ms
23,552 KB
testcase_08 AC 307 ms
28,288 KB
testcase_09 AC 194 ms
21,504 KB
testcase_10 AC 71 ms
13,824 KB
testcase_11 AC 157 ms
19,200 KB
testcase_12 AC 124 ms
18,944 KB
testcase_13 AC 61 ms
13,824 KB
testcase_14 AC 72 ms
13,568 KB
testcase_15 AC 60 ms
13,056 KB
testcase_16 AC 286 ms
27,392 KB
testcase_17 AC 229 ms
18,944 KB
testcase_18 AC 653 ms
29,184 KB
testcase_19 AC 185 ms
15,744 KB
testcase_20 AC 746 ms
42,112 KB
testcase_21 AC 752 ms
30,720 KB
testcase_22 AC 533 ms
21,376 KB
testcase_23 AC 613 ms
25,216 KB
testcase_24 AC 673 ms
31,104 KB
testcase_25 AC 70 ms
14,208 KB
testcase_26 AC 440 ms
33,152 KB
testcase_27 AC 308 ms
28,928 KB
testcase_28 AC 965 ms
51,712 KB
testcase_29 AC 965 ms
51,712 KB
testcase_30 AC 968 ms
51,584 KB
testcase_31 AC 969 ms
51,712 KB
testcase_32 AC 969 ms
51,456 KB
testcase_33 AC 970 ms
51,712 KB
testcase_34 AC 969 ms
51,584 KB
testcase_35 AC 967 ms
51,712 KB
testcase_36 AC 965 ms
51,712 KB
testcase_37 AC 969 ms
51,712 KB
testcase_38 AC 967 ms
51,712 KB
testcase_39 AC 973 ms
51,584 KB
testcase_40 AC 970 ms
51,584 KB
testcase_41 AC 967 ms
51,712 KB
testcase_42 AC 971 ms
51,584 KB
testcase_43 AC 974 ms
51,584 KB
testcase_44 AC 975 ms
51,456 KB
testcase_45 AC 971 ms
51,584 KB
testcase_46 AC 971 ms
51,712 KB
testcase_47 AC 978 ms
51,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import collections
import bisect
import itertools
import decimal

# import numpy as np

# sys.setrecursionlimit(10 ** 6)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n, m = ns()
    mat = [na() for _ in range(n)]

    res = []
    for i in range(n):
        tmp = 0
        for j in range(m):
            tmp += mat[i][j]
        res.append(tmp)

    dp = [[0] * 2 for _ in range(n + 1)]

    ans = 0
    for i in range(n):
        for j in range(i + 1, n + 1):
            dp[j][0] = max(dp[j][0], dp[i][1] - res[j - 1])
            dp[j][1] = max(dp[j][1], dp[i][0] + res[j - 1])
            ans = max(ans, dp[j][0], dp[j][1])

    print(ans)


if __name__ == '__main__':
    main()
0