結果

問題 No.1199 お菓子配り-2
ユーザー magmag
提出日時 2020-09-22 13:40:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 758 bytes
コンパイル時間 1,569 ms
コンパイル使用メモリ 168,856 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-08 08:42:48
合計ジャッジ時間 8,941 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 78 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 6 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 25 ms
4,380 KB
testcase_12 AC 24 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 25 ms
4,376 KB
testcase_18 WA -
testcase_19 AC 15 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 31 ms
4,376 KB
testcase_23 WA -
testcase_24 AC 59 ms
4,380 KB
testcase_25 AC 10 ms
4,380 KB
testcase_26 AC 66 ms
4,376 KB
testcase_27 AC 54 ms
4,376 KB
testcase_28 AC 123 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 123 ms
4,380 KB
testcase_32 AC 123 ms
4,380 KB
testcase_33 AC 123 ms
4,376 KB
testcase_34 AC 124 ms
4,380 KB
testcase_35 AC 123 ms
4,376 KB
testcase_36 AC 123 ms
4,376 KB
testcase_37 WA -
testcase_38 AC 124 ms
4,380 KB
testcase_39 AC 123 ms
4,376 KB
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>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n,m;cin>>n>>m;
  ll hoge;
  vector<ll> a(n,0);
  rep(i,n){
    rep(j,m){
      cin>>hoge;
      a[i]+=hoge;
    }
  }

  vector<vector<ll>> dp(n,vector<ll>(2,0));
  rep(i,n-1){
    dp[i+1][0]=max(dp[i][0],dp[i][1]+a[i+1]);
    dp[i+1][1]=max(dp[i][1],dp[i][0]-a[i+1]);
  }
  /*
  rep(i,n){
    cout<<a[i]<<" ";
  }
  cout<<endl;
  cout<<endl;
  rep(i,n){
    cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
  }
  */
  cout<<max(dp[n-1][0],dp[n-1][0])<<endl;
}
0