結果

問題 No.1199 お菓子配り-2
ユーザー w2w2w2w2
提出日時 2020-08-28 21:51:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 136 ms / 1,000 ms
コード長 1,229 bytes
コンパイル時間 1,785 ms
コンパイル使用メモリ 165,452 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 14:44:42
合計ジャッジ時間 9,194 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 35 ms
5,376 KB
testcase_04 AC 82 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 6 ms
5,376 KB
testcase_07 AC 41 ms
5,376 KB
testcase_08 AC 57 ms
5,376 KB
testcase_09 AC 35 ms
5,376 KB
testcase_10 AC 10 ms
5,376 KB
testcase_11 AC 27 ms
5,376 KB
testcase_12 AC 27 ms
5,376 KB
testcase_13 AC 10 ms
5,376 KB
testcase_14 AC 9 ms
5,376 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 55 ms
5,376 KB
testcase_17 AC 27 ms
5,376 KB
testcase_18 AC 57 ms
5,376 KB
testcase_19 AC 17 ms
5,376 KB
testcase_20 AC 102 ms
5,376 KB
testcase_21 AC 61 ms
5,376 KB
testcase_22 AC 33 ms
5,376 KB
testcase_23 AC 47 ms
5,376 KB
testcase_24 AC 63 ms
5,376 KB
testcase_25 AC 11 ms
5,376 KB
testcase_26 AC 71 ms
5,376 KB
testcase_27 AC 57 ms
5,376 KB
testcase_28 AC 131 ms
5,376 KB
testcase_29 AC 130 ms
5,376 KB
testcase_30 AC 136 ms
5,376 KB
testcase_31 AC 136 ms
5,376 KB
testcase_32 AC 135 ms
5,376 KB
testcase_33 AC 134 ms
5,376 KB
testcase_34 AC 132 ms
5,376 KB
testcase_35 AC 133 ms
5,376 KB
testcase_36 AC 134 ms
5,376 KB
testcase_37 AC 135 ms
5,376 KB
testcase_38 AC 135 ms
5,376 KB
testcase_39 AC 135 ms
5,376 KB
testcase_40 AC 135 ms
5,376 KB
testcase_41 AC 131 ms
5,376 KB
testcase_42 AC 134 ms
5,376 KB
testcase_43 AC 134 ms
5,376 KB
testcase_44 AC 134 ms
5,376 KB
testcase_45 AC 136 ms
5,376 KB
testcase_46 AC 132 ms
5,376 KB
testcase_47 AC 131 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N,M;
    cin >> N >> M;
    vector<ll> A(N);
    REP(i,N){
        REP(l,M){
            ll tmp;
            cin >> tmp;
            A[i] += tmp;
        }
    }
    vector<ll> dpse(N+1,-10000000000000000);
    vector<ll> dphu(N+1,-10000000000000000);
    dpse[0] = 0;
    REP(i,N){
        dpse[i+1] = max(dphu[i] - A[i],dpse[i]);
        dphu[i+1] = max(dpse[i] + A[i],dphu[i]);
    }
    cout << max(dpse[N],dphu[N]) << "\n";
}
0