結果

問題 No.1199 お菓子配り-2
ユーザー DriceDrice
提出日時 2020-08-28 22:20:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 127 ms / 1,000 ms
コード長 623 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 31,788 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-08 22:49:02
合計ジャッジ時間 7,736 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 32 ms
4,384 KB
testcase_04 AC 80 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 39 ms
4,376 KB
testcase_08 AC 56 ms
4,380 KB
testcase_09 AC 31 ms
4,380 KB
testcase_10 AC 9 ms
4,380 KB
testcase_11 AC 25 ms
4,380 KB
testcase_12 AC 25 ms
4,376 KB
testcase_13 AC 10 ms
4,384 KB
testcase_14 AC 8 ms
4,376 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 53 ms
4,380 KB
testcase_17 AC 26 ms
4,380 KB
testcase_18 AC 55 ms
4,380 KB
testcase_19 AC 15 ms
4,384 KB
testcase_20 AC 93 ms
4,380 KB
testcase_21 AC 57 ms
4,380 KB
testcase_22 AC 30 ms
4,380 KB
testcase_23 AC 43 ms
4,380 KB
testcase_24 AC 59 ms
4,380 KB
testcase_25 AC 10 ms
4,376 KB
testcase_26 AC 68 ms
4,376 KB
testcase_27 AC 53 ms
4,380 KB
testcase_28 AC 122 ms
4,376 KB
testcase_29 AC 123 ms
4,380 KB
testcase_30 AC 119 ms
4,376 KB
testcase_31 AC 119 ms
4,380 KB
testcase_32 AC 119 ms
4,376 KB
testcase_33 AC 125 ms
4,380 KB
testcase_34 AC 124 ms
4,376 KB
testcase_35 AC 125 ms
4,380 KB
testcase_36 AC 121 ms
4,380 KB
testcase_37 AC 123 ms
4,376 KB
testcase_38 AC 119 ms
4,380 KB
testcase_39 AC 117 ms
4,380 KB
testcase_40 AC 125 ms
4,380 KB
testcase_41 AC 124 ms
4,380 KB
testcase_42 AC 124 ms
4,380 KB
testcase_43 AC 127 ms
4,380 KB
testcase_44 AC 125 ms
4,380 KB
testcase_45 AC 126 ms
4,380 KB
testcase_46 AC 119 ms
4,376 KB
testcase_47 AC 127 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
const long long inf = 1e17+7;
long long f[1005][2];
long long sum[1005];

long long max(long long a,long long b){ return a>b?a:b; }

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i++){
        sum[i] = 0;
        for(int j = 1; j <= m; j++){
            long long u;
            scanf("%lld",&u);
            sum[i] += u;
        }
    }
    f[0][0] = 0;
    f[0][1] = -inf;
    for(int i = 1; i <= n; i++){
        f[i][0] = max(f[i-1][0],f[i-1][1]-sum[i]);
        f[i][1] = max(f[i-1][1],f[i-1][0]+sum[i]);
    }
    printf("%lld\n",max(f[n][0],f[n][1]));
    return 0;
}
0