結果

問題 No.1199 お菓子配り-2
ユーザー mmn15277198mmn15277198
提出日時 2021-02-08 16:54:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 401 ms / 1,000 ms
コード長 644 bytes
コンパイル時間 2,027 ms
コンパイル使用メモリ 73,932 KB
実行使用メモリ 5,244 KB
最終ジャッジ日時 2023-09-19 06:48:17
合計ジャッジ時間 17,517 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,992 KB
testcase_01 AC 1 ms
4,992 KB
testcase_02 AC 1 ms
5,052 KB
testcase_03 AC 99 ms
4,988 KB
testcase_04 AC 249 ms
4,988 KB
testcase_05 AC 9 ms
5,052 KB
testcase_06 AC 15 ms
4,992 KB
testcase_07 AC 121 ms
4,996 KB
testcase_08 AC 167 ms
5,004 KB
testcase_09 AC 101 ms
5,056 KB
testcase_10 AC 25 ms
4,996 KB
testcase_11 AC 78 ms
4,992 KB
testcase_12 AC 77 ms
5,056 KB
testcase_13 AC 27 ms
4,996 KB
testcase_14 AC 23 ms
5,244 KB
testcase_15 AC 19 ms
5,000 KB
testcase_16 AC 162 ms
4,992 KB
testcase_17 AC 78 ms
4,992 KB
testcase_18 AC 169 ms
5,052 KB
testcase_19 AC 45 ms
4,992 KB
testcase_20 AC 303 ms
4,996 KB
testcase_21 AC 186 ms
4,992 KB
testcase_22 AC 97 ms
5,064 KB
testcase_23 AC 136 ms
5,060 KB
testcase_24 AC 186 ms
5,052 KB
testcase_25 AC 29 ms
4,992 KB
testcase_26 AC 210 ms
5,056 KB
testcase_27 AC 169 ms
4,992 KB
testcase_28 AC 398 ms
5,052 KB
testcase_29 AC 397 ms
4,844 KB
testcase_30 AC 398 ms
5,112 KB
testcase_31 AC 400 ms
5,052 KB
testcase_32 AC 397 ms
4,992 KB
testcase_33 AC 401 ms
5,052 KB
testcase_34 AC 398 ms
5,112 KB
testcase_35 AC 396 ms
5,000 KB
testcase_36 AC 396 ms
4,988 KB
testcase_37 AC 397 ms
4,988 KB
testcase_38 AC 397 ms
5,000 KB
testcase_39 AC 397 ms
5,056 KB
testcase_40 AC 397 ms
4,988 KB
testcase_41 AC 396 ms
4,988 KB
testcase_42 AC 401 ms
5,056 KB
testcase_43 AC 398 ms
4,996 KB
testcase_44 AC 398 ms
4,992 KB
testcase_45 AC 398 ms
4,988 KB
testcase_46 AC 399 ms
4,988 KB
testcase_47 AC 399 ms
4,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const int INF = 100100100;

int main(){
    int n , m;
    cin >> n >> m;
    vector<ll> a(n + 1 , 0);
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < m; j++){
            ll now;
            cin >> now;
            a[i] += now;
        }
    }
    vector<vector<ll>> dp(n + 10 , vector<ll>(2 , 0));
    for(int i = 1; i <= n; i++){
        dp[i][1] = max({dp[i - 1][1] , dp[i - 1][0] + a[i] , a[i]});
        dp[i][0] = max(dp[i - 1][0] , dp[i - 1][1] - a[i]);
    }
    cout << max(dp[n][1] , dp[n][0]) << endl;
    return 0;
}
0