結果

問題 No.1199 お菓子配り-2
ユーザー hedwig100hedwig100
提出日時 2020-08-28 22:17:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 132 ms / 1,000 ms
コード長 980 bytes
コンパイル時間 1,485 ms
コンパイル使用メモリ 169,708 KB
実行使用メモリ 11,060 KB
最終ジャッジ日時 2023-08-08 22:48:38
合計ジャッジ時間 9,169 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 34 ms
5,428 KB
testcase_04 AC 83 ms
9,664 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 6 ms
4,376 KB
testcase_07 AC 40 ms
4,704 KB
testcase_08 AC 54 ms
4,544 KB
testcase_09 AC 33 ms
4,380 KB
testcase_10 AC 10 ms
4,380 KB
testcase_11 AC 26 ms
4,384 KB
testcase_12 AC 25 ms
4,380 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 8 ms
4,376 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 53 ms
4,712 KB
testcase_17 AC 26 ms
4,896 KB
testcase_18 AC 59 ms
9,576 KB
testcase_19 AC 16 ms
4,592 KB
testcase_20 AC 99 ms
9,128 KB
testcase_21 AC 65 ms
10,772 KB
testcase_22 AC 37 ms
8,848 KB
testcase_23 AC 50 ms
9,332 KB
testcase_24 AC 65 ms
9,604 KB
testcase_25 AC 10 ms
4,376 KB
testcase_26 AC 70 ms
5,900 KB
testcase_27 AC 56 ms
4,828 KB
testcase_28 AC 131 ms
11,052 KB
testcase_29 AC 131 ms
10,916 KB
testcase_30 AC 131 ms
11,032 KB
testcase_31 AC 130 ms
11,040 KB
testcase_32 AC 130 ms
10,912 KB
testcase_33 AC 131 ms
10,892 KB
testcase_34 AC 130 ms
10,896 KB
testcase_35 AC 131 ms
10,896 KB
testcase_36 AC 131 ms
10,920 KB
testcase_37 AC 131 ms
10,892 KB
testcase_38 AC 131 ms
11,060 KB
testcase_39 AC 131 ms
10,972 KB
testcase_40 AC 131 ms
10,880 KB
testcase_41 AC 130 ms
10,960 KB
testcase_42 AC 130 ms
10,932 KB
testcase_43 AC 131 ms
11,044 KB
testcase_44 AC 131 ms
10,968 KB
testcase_45 AC 132 ms
11,044 KB
testcase_46 AC 131 ms
10,924 KB
testcase_47 AC 130 ms
10,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N,M; cin >> N >> M;
    vector<ll> A(N);
    rep(i,N) {
        ll x = 0;
        rep(j,M) {
            ll a; cin >> a;
            x += a;
        }
        A[i] = x;
    }

    vector<vector<ll>> dp(N + 1,vector<ll>(N + 1,0));
    rep(i,N) {
        rep(j,N) {
            dp[i + 1][j + 1] = max(dp[i][j + 1],dp[i][j] + (j%2 ? -1: 1) * A[i]);
        }
    }
    ll ans = 0;
    rep(i,N + 1) {
        ans = max(ans,dp[N][i]);
    }
    cout << ans << '\n'; 
    return 0;
}
0