結果

問題 No.1199 お菓子配り-2
ユーザー hedwig100hedwig100
提出日時 2020-08-28 22:17:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 145 ms / 1,000 ms
コード長 980 bytes
コンパイル時間 1,773 ms
コンパイル使用メモリ 168,364 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-26 14:58:52
合計ジャッジ時間 9,666 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 37 ms
5,888 KB
testcase_04 AC 91 ms
9,856 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 6 ms
5,376 KB
testcase_07 AC 44 ms
5,376 KB
testcase_08 AC 60 ms
5,376 KB
testcase_09 AC 36 ms
5,376 KB
testcase_10 AC 10 ms
5,376 KB
testcase_11 AC 29 ms
5,376 KB
testcase_12 AC 28 ms
5,376 KB
testcase_13 AC 11 ms
5,376 KB
testcase_14 AC 10 ms
5,376 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 58 ms
5,376 KB
testcase_17 AC 29 ms
5,376 KB
testcase_18 AC 64 ms
9,728 KB
testcase_19 AC 18 ms
5,376 KB
testcase_20 AC 108 ms
9,216 KB
testcase_21 AC 70 ms
11,008 KB
testcase_22 AC 40 ms
8,960 KB
testcase_23 AC 54 ms
9,600 KB
testcase_24 AC 71 ms
9,728 KB
testcase_25 AC 12 ms
5,376 KB
testcase_26 AC 76 ms
6,016 KB
testcase_27 AC 61 ms
5,376 KB
testcase_28 AC 143 ms
11,136 KB
testcase_29 AC 143 ms
11,264 KB
testcase_30 AC 143 ms
11,136 KB
testcase_31 AC 143 ms
11,264 KB
testcase_32 AC 143 ms
11,264 KB
testcase_33 AC 145 ms
11,136 KB
testcase_34 AC 142 ms
11,008 KB
testcase_35 AC 142 ms
11,136 KB
testcase_36 AC 142 ms
11,264 KB
testcase_37 AC 143 ms
11,008 KB
testcase_38 AC 144 ms
11,264 KB
testcase_39 AC 143 ms
11,008 KB
testcase_40 AC 142 ms
11,136 KB
testcase_41 AC 142 ms
11,136 KB
testcase_42 AC 142 ms
11,008 KB
testcase_43 AC 142 ms
11,264 KB
testcase_44 AC 142 ms
11,136 KB
testcase_45 AC 142 ms
11,264 KB
testcase_46 AC 142 ms
11,264 KB
testcase_47 AC 141 ms
11,136 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