結果

問題 No.1199 お菓子配り-2
ユーザー tcltktcltk
提出日時 2021-01-16 08:09:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 384 ms / 1,000 ms
コード長 837 bytes
コンパイル時間 889 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 87,116 KB
最終ジャッジ日時 2023-08-18 04:31:52
合計ジャッジ時間 25,151 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 245 ms
83,420 KB
testcase_01 AC 238 ms
83,276 KB
testcase_02 AC 251 ms
83,380 KB
testcase_03 AC 345 ms
86,188 KB
testcase_04 AC 337 ms
86,104 KB
testcase_05 AC 248 ms
84,176 KB
testcase_06 AC 267 ms
85,936 KB
testcase_07 AC 277 ms
85,888 KB
testcase_08 AC 299 ms
86,080 KB
testcase_09 AC 285 ms
86,044 KB
testcase_10 AC 271 ms
86,248 KB
testcase_11 AC 274 ms
86,132 KB
testcase_12 AC 281 ms
85,920 KB
testcase_13 AC 249 ms
85,924 KB
testcase_14 AC 266 ms
86,004 KB
testcase_15 AC 256 ms
85,976 KB
testcase_16 AC 318 ms
86,248 KB
testcase_17 AC 308 ms
85,968 KB
testcase_18 AC 306 ms
86,216 KB
testcase_19 AC 258 ms
85,848 KB
testcase_20 AC 349 ms
86,696 KB
testcase_21 AC 304 ms
86,052 KB
testcase_22 AC 293 ms
86,044 KB
testcase_23 AC 290 ms
85,964 KB
testcase_24 AC 313 ms
85,988 KB
testcase_25 AC 255 ms
85,884 KB
testcase_26 AC 317 ms
86,044 KB
testcase_27 AC 301 ms
86,088 KB
testcase_28 AC 380 ms
86,868 KB
testcase_29 AC 364 ms
86,864 KB
testcase_30 AC 374 ms
86,696 KB
testcase_31 AC 356 ms
86,904 KB
testcase_32 AC 380 ms
86,964 KB
testcase_33 AC 370 ms
86,844 KB
testcase_34 AC 384 ms
86,956 KB
testcase_35 AC 361 ms
86,632 KB
testcase_36 AC 375 ms
86,708 KB
testcase_37 AC 366 ms
86,776 KB
testcase_38 AC 382 ms
87,000 KB
testcase_39 AC 362 ms
86,924 KB
testcase_40 AC 382 ms
86,724 KB
testcase_41 AC 363 ms
87,116 KB
testcase_42 AC 379 ms
86,716 KB
testcase_43 AC 362 ms
86,796 KB
testcase_44 AC 382 ms
86,940 KB
testcase_45 AC 359 ms
86,828 KB
testcase_46 AC 371 ms
86,740 KB
testcase_47 AC 367 ms
86,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#region Header
#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
from queue import PriorityQueue
import bisect
import heapq

def input():
    return sys.stdin.readline()[:-1]

sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """# paste here...
# """
# sys.stdin = io.StringIO(_INPUT)


def main():
    N, M = map(int, input().split())
    s = []
    for _ in range(N):
        s.append(sum(list(map(int, input().split()))))

    dp = [[0, 0] for _ in range(N)]
    dp[0][0] = 0
    dp[0][1] = s[0]
    for i in range(1, N):
        dp[i][0] = max(dp[i-1][0], dp[i-1][1] - s[i])
        dp[i][1] = max(dp[i-1][1], dp[i-1][0] + s[i])

    v = max(dp[N-1])
    print(v)


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