結果

問題 No.1199 お菓子配り-2
ユーザー uni_pythonuni_python
提出日時 2020-08-28 21:54:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 192 ms / 1,000 ms
コード長 732 bytes
コンパイル時間 1,188 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 78,000 KB
最終ジャッジ日時 2023-08-08 22:39:29
合計ジャッジ時間 11,389 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
71,344 KB
testcase_01 AC 61 ms
71,488 KB
testcase_02 AC 61 ms
71,152 KB
testcase_03 AC 100 ms
76,900 KB
testcase_04 AC 143 ms
77,460 KB
testcase_05 AC 66 ms
75,992 KB
testcase_06 AC 73 ms
76,240 KB
testcase_07 AC 103 ms
76,844 KB
testcase_08 AC 117 ms
77,156 KB
testcase_09 AC 101 ms
77,020 KB
testcase_10 AC 79 ms
76,724 KB
testcase_11 AC 96 ms
76,904 KB
testcase_12 AC 91 ms
76,740 KB
testcase_13 AC 74 ms
76,672 KB
testcase_14 AC 76 ms
76,976 KB
testcase_15 AC 75 ms
76,324 KB
testcase_16 AC 117 ms
76,952 KB
testcase_17 AC 96 ms
76,900 KB
testcase_18 AC 120 ms
76,964 KB
testcase_19 AC 84 ms
76,944 KB
testcase_20 AC 144 ms
77,360 KB
testcase_21 AC 122 ms
76,972 KB
testcase_22 AC 101 ms
76,704 KB
testcase_23 AC 112 ms
77,036 KB
testcase_24 AC 124 ms
77,260 KB
testcase_25 AC 81 ms
76,404 KB
testcase_26 AC 125 ms
77,340 KB
testcase_27 AC 115 ms
76,888 KB
testcase_28 AC 177 ms
77,868 KB
testcase_29 AC 189 ms
77,688 KB
testcase_30 AC 182 ms
77,748 KB
testcase_31 AC 176 ms
77,892 KB
testcase_32 AC 169 ms
78,000 KB
testcase_33 AC 171 ms
77,752 KB
testcase_34 AC 168 ms
77,808 KB
testcase_35 AC 169 ms
77,864 KB
testcase_36 AC 192 ms
77,700 KB
testcase_37 AC 170 ms
77,976 KB
testcase_38 AC 173 ms
77,976 KB
testcase_39 AC 178 ms
77,816 KB
testcase_40 AC 177 ms
77,848 KB
testcase_41 AC 173 ms
77,796 KB
testcase_42 AC 170 ms
77,884 KB
testcase_43 AC 170 ms
77,944 KB
testcase_44 AC 170 ms
77,728 KB
testcase_45 AC 166 ms
77,812 KB
testcase_46 AC 180 ms
77,792 KB
testcase_47 AC 179 ms
77,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    A=[0]*N
    for i in range(N):
        a=LI()
        A[i]=sum(a)
    
    dp=[[0]*3 for _ in range(N)]
    # dp[i][j]はi個目まで見た時のmax,j=0,1でi個目が+,-
    
    dp[0][0]=A[0]
    
    for i in range(1,N):
        
        
        for j in range(i):
            dp[i][0]=max(dp[i][0], dp[j][1]+A[i],A[i])
            dp[i][1]=max(dp[i][1], dp[j][0]-A[i])
            

    ans=0
    for i in range(N):
        ans=max(ans,dp[i][0])
        
    print(ans)
        
        
        
            
    


main()
0