結果

問題 No.1199 お菓子配り-2
ユーザー uni_pythonuni_python
提出日時 2020-08-28 21:54:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 175 ms / 1,000 ms
コード長 732 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 82,336 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2024-04-26 14:49:19
合計ジャッジ時間 10,063 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
51,968 KB
testcase_01 AC 37 ms
52,096 KB
testcase_02 AC 36 ms
52,436 KB
testcase_03 AC 84 ms
75,904 KB
testcase_04 AC 134 ms
76,136 KB
testcase_05 AC 44 ms
62,336 KB
testcase_06 AC 51 ms
67,456 KB
testcase_07 AC 89 ms
76,160 KB
testcase_08 AC 99 ms
75,776 KB
testcase_09 AC 81 ms
76,032 KB
testcase_10 AC 58 ms
75,580 KB
testcase_11 AC 75 ms
75,648 KB
testcase_12 AC 75 ms
75,776 KB
testcase_13 AC 59 ms
75,392 KB
testcase_14 AC 57 ms
73,600 KB
testcase_15 AC 55 ms
70,528 KB
testcase_16 AC 99 ms
76,544 KB
testcase_17 AC 80 ms
76,212 KB
testcase_18 AC 107 ms
76,032 KB
testcase_19 AC 72 ms
75,940 KB
testcase_20 AC 141 ms
76,336 KB
testcase_21 AC 116 ms
76,056 KB
testcase_22 AC 91 ms
75,776 KB
testcase_23 AC 102 ms
76,160 KB
testcase_24 AC 115 ms
75,904 KB
testcase_25 AC 60 ms
75,264 KB
testcase_26 AC 116 ms
76,404 KB
testcase_27 AC 104 ms
75,936 KB
testcase_28 AC 168 ms
76,544 KB
testcase_29 AC 167 ms
76,720 KB
testcase_30 AC 166 ms
76,672 KB
testcase_31 AC 172 ms
76,840 KB
testcase_32 AC 169 ms
77,056 KB
testcase_33 AC 171 ms
76,752 KB
testcase_34 AC 168 ms
76,400 KB
testcase_35 AC 169 ms
76,672 KB
testcase_36 AC 167 ms
76,672 KB
testcase_37 AC 168 ms
76,544 KB
testcase_38 AC 169 ms
76,544 KB
testcase_39 AC 171 ms
76,416 KB
testcase_40 AC 168 ms
76,912 KB
testcase_41 AC 174 ms
76,464 KB
testcase_42 AC 168 ms
76,288 KB
testcase_43 AC 175 ms
76,336 KB
testcase_44 AC 169 ms
76,568 KB
testcase_45 AC 170 ms
76,928 KB
testcase_46 AC 164 ms
76,544 KB
testcase_47 AC 158 ms
76,416 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