結果

問題 No.1199 お菓子配り-2
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-08-29 15:36:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 463 ms / 1,000 ms
コード長 764 bytes
コンパイル時間 1,870 ms
コンパイル使用メモリ 167,540 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 22:15:45
合計ジャッジ時間 21,213 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 113 ms
5,376 KB
testcase_04 AC 283 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 17 ms
5,376 KB
testcase_07 AC 135 ms
5,376 KB
testcase_08 AC 186 ms
5,376 KB
testcase_09 AC 114 ms
5,376 KB
testcase_10 AC 30 ms
5,376 KB
testcase_11 AC 88 ms
5,376 KB
testcase_12 AC 88 ms
5,376 KB
testcase_13 AC 31 ms
5,376 KB
testcase_14 AC 27 ms
5,376 KB
testcase_15 AC 21 ms
5,376 KB
testcase_16 AC 181 ms
5,376 KB
testcase_17 AC 87 ms
5,376 KB
testcase_18 AC 190 ms
5,376 KB
testcase_19 AC 50 ms
5,376 KB
testcase_20 AC 339 ms
5,376 KB
testcase_21 AC 209 ms
5,376 KB
testcase_22 AC 110 ms
5,376 KB
testcase_23 AC 154 ms
5,376 KB
testcase_24 AC 213 ms
5,376 KB
testcase_25 AC 33 ms
5,376 KB
testcase_26 AC 238 ms
5,376 KB
testcase_27 AC 190 ms
5,376 KB
testcase_28 AC 449 ms
5,376 KB
testcase_29 AC 439 ms
5,376 KB
testcase_30 AC 441 ms
5,376 KB
testcase_31 AC 443 ms
5,376 KB
testcase_32 AC 441 ms
5,376 KB
testcase_33 AC 439 ms
5,376 KB
testcase_34 AC 438 ms
5,376 KB
testcase_35 AC 441 ms
5,376 KB
testcase_36 AC 442 ms
5,376 KB
testcase_37 AC 463 ms
5,376 KB
testcase_38 AC 439 ms
5,376 KB
testcase_39 AC 438 ms
5,376 KB
testcase_40 AC 439 ms
5,376 KB
testcase_41 AC 438 ms
5,376 KB
testcase_42 AC 440 ms
5,376 KB
testcase_43 AC 439 ms
5,376 KB
testcase_44 AC 442 ms
5,376 KB
testcase_45 AC 439 ms
5,376 KB
testcase_46 AC 441 ms
5,376 KB
testcase_47 AC 441 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.29 15:36:38
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n,m;cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            ll b;cin >> b;
            a[i] += b;
        }
    }
    constexpr long long LLINF = 1e18 + 1;
    vector<vector<ll>> dp(n+1,vector<ll>(2,-LLINF));
    dp[0][1] = 0;
    ll one_max = 0, zero_max = -LLINF;
    for (int i = 0; i < n; i++) {
        dp[i + 1][0] = one_max + a[i];
        dp[i + 1][1] = zero_max - a[i];
        one_max = max(one_max,dp[i + 1][1]);
        zero_max = max(zero_max,dp[i + 1][0]);
    }
    cout << zero_max << endl;
    return 0;
}
0