結果

問題 No.1199 お菓子配り-2
ユーザー YamaKasaYamaKasa
提出日時 2020-09-22 17:08:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 406 ms / 1,000 ms
コード長 551 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 163,632 KB
実行使用メモリ 11,464 KB
最終ジャッジ日時 2023-09-08 13:38:07
合計ジャッジ時間 19,931 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 101 ms
5,400 KB
testcase_04 AC 252 ms
8,316 KB
testcase_05 AC 9 ms
4,380 KB
testcase_06 AC 15 ms
4,380 KB
testcase_07 AC 123 ms
5,740 KB
testcase_08 AC 169 ms
6,720 KB
testcase_09 AC 102 ms
5,344 KB
testcase_10 AC 26 ms
4,380 KB
testcase_11 AC 79 ms
4,832 KB
testcase_12 AC 78 ms
4,852 KB
testcase_13 AC 28 ms
4,380 KB
testcase_14 AC 23 ms
4,380 KB
testcase_15 AC 19 ms
4,380 KB
testcase_16 AC 164 ms
6,488 KB
testcase_17 AC 78 ms
4,812 KB
testcase_18 AC 171 ms
6,612 KB
testcase_19 AC 45 ms
4,376 KB
testcase_20 AC 309 ms
9,272 KB
testcase_21 AC 188 ms
7,168 KB
testcase_22 AC 99 ms
5,504 KB
testcase_23 AC 137 ms
6,340 KB
testcase_24 AC 189 ms
7,032 KB
testcase_25 AC 29 ms
4,376 KB
testcase_26 AC 214 ms
7,568 KB
testcase_27 AC 174 ms
6,740 KB
testcase_28 AC 402 ms
11,336 KB
testcase_29 AC 400 ms
11,200 KB
testcase_30 AC 401 ms
11,152 KB
testcase_31 AC 406 ms
11,256 KB
testcase_32 AC 401 ms
11,224 KB
testcase_33 AC 399 ms
11,156 KB
testcase_34 AC 400 ms
11,160 KB
testcase_35 AC 402 ms
11,332 KB
testcase_36 AC 402 ms
11,156 KB
testcase_37 AC 402 ms
11,152 KB
testcase_38 AC 400 ms
11,268 KB
testcase_39 AC 400 ms
11,196 KB
testcase_40 AC 404 ms
11,160 KB
testcase_41 AC 401 ms
11,332 KB
testcase_42 AC 400 ms
11,208 KB
testcase_43 AC 402 ms
11,180 KB
testcase_44 AC 400 ms
11,268 KB
testcase_45 AC 399 ms
11,464 KB
testcase_46 AC 401 ms
11,220 KB
testcase_47 AC 402 ms
11,208 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:17:18: 警告: ‘*b[0]’ may be used uninitialized [-Wmaybe-uninitialized]
   17 |     d[0][0] = b[0];
      |               ~~~^

ソースコード

diff #

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

int main() {
    int N, M;
    cin >> N >> M;
    ll A[N][M];
    ll b[N]{};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
            b[i] += A[i][j];
        }
    }
    ll d[N][2]{};
    d[0][0] = b[0];
    for (int i = 0; i < N - 1; i++) {
        d[i + 1][0] = max(d[i][1] + b[i + 1], d[i][0]);
        d[i + 1][1] = max(d[i][1], d[i][0] - b[i + 1]);
    }
    cout << max(d[N - 1][0], d[N - 1][1]) << "\n";
    return 0;
}
0