結果

問題 No.1199 お菓子配り-2
ユーザー RiRinbaruRiRinbaru
提出日時 2024-02-29 04:31:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,233 bytes
コンパイル時間 2,684 ms
コンパイル使用メモリ 179,680 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-29 04:31:57
合計ジャッジ時間 13,170 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, p, n) for (ll i = p; i < (ll)(n); i++)
#define rep2(i, p, n) for(ll i = p; i >= (ll)(n); i-- )
using namespace std;
using ll = long long;
using ld = long double;
double pi=3.141592653589793;
const long long inf=2*1e9;
const long long linf=8*1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//atcoder
#include <atcoder/modint>
#include <atcoder/dsu>
#include <atcoder/segtree>
#include <atcoder/lazysegtree>
using namespace atcoder;
using mint1 = modint1000000007;
using mint2 = modint998244353;

/*
//多倍長整数
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using ci = cpp_int;
//ciで定義
//https://boostjp.github.io/tips/multiprec-int.html
//常時使っているとdouble >> llの適切なキャストができない(ll sqrt(整数)等)ので、基本はコメントアウト
*/


//拡張ユークリッド
//input: ll a,b
//output: ax+by=gcd(a,b)の解(x,y)(<max(a, b))
pair<long long, long long> extgcd(long long a, long long b) {
    if (b == 0) return make_pair(1, 0);
    long long x, y;
    tie(y, x) = extgcd(b, a % b);
    y -= a / b * x;
    return make_pair(x, y);
}

//素数列挙
//output: (void)N以下の整数のうち素数であるものをsosuuに返す
void SR(ll N, vector<ll> &sosuu) { 
    vector<bool> testSR(N+1, true);
    for(int i=2; i<=N; i++) {
        if (testSR.at(i)) {
            sosuu.push_back(i);
            for(int j=i*2; j<=N; j+=i) {
                testSR.at(j)=false;
            }
        }
    }
}

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

    ll N, M;
    cin >> N >> M;
    vector<ll> li(N);
    rep(i, 0, N) {
        ll sum=0;
        rep(j, 0, M) {
            ll A;
            cin >> A;
            sum+=A;
        }
        li.at(i)=sum;
    }
    vector<ll> dp1(N), dp2(N);
    dp1.at(0)=li.at(0);
    rep(i, 1, N) {
        chmax(dp2.at(i), dp1.at(i-1)-li.at(i));
        chmax(dp1.at(i), dp2.at(i-1)+li.at(i));
    }
    cout << max(dp1.at(N-1), dp2.at(N-1));
}
0