結果

問題 No.1199 お菓子配り-2
ユーザー AuroraAurora
提出日時 2021-09-12 12:34:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 403 ms / 1,000 ms
コード長 623 bytes
コンパイル時間 2,968 ms
コンパイル使用メモリ 170,260 KB
実行使用メモリ 11,528 KB
最終ジャッジ日時 2023-09-06 06:09:25
合計ジャッジ時間 22,730 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 100 ms
5,460 KB
testcase_04 AC 250 ms
8,224 KB
testcase_05 AC 9 ms
4,380 KB
testcase_06 AC 15 ms
4,380 KB
testcase_07 AC 119 ms
5,668 KB
testcase_08 AC 162 ms
6,576 KB
testcase_09 AC 98 ms
5,248 KB
testcase_10 AC 26 ms
4,376 KB
testcase_11 AC 78 ms
4,800 KB
testcase_12 AC 73 ms
4,756 KB
testcase_13 AC 25 ms
4,380 KB
testcase_14 AC 22 ms
4,380 KB
testcase_15 AC 19 ms
4,380 KB
testcase_16 AC 159 ms
6,656 KB
testcase_17 AC 73 ms
5,008 KB
testcase_18 AC 160 ms
6,824 KB
testcase_19 AC 43 ms
4,380 KB
testcase_20 AC 300 ms
9,268 KB
testcase_21 AC 183 ms
6,964 KB
testcase_22 AC 97 ms
5,348 KB
testcase_23 AC 136 ms
6,020 KB
testcase_24 AC 184 ms
7,120 KB
testcase_25 AC 27 ms
4,380 KB
testcase_26 AC 206 ms
7,744 KB
testcase_27 AC 168 ms
6,720 KB
testcase_28 AC 391 ms
11,180 KB
testcase_29 AC 391 ms
11,168 KB
testcase_30 AC 392 ms
11,240 KB
testcase_31 AC 397 ms
11,160 KB
testcase_32 AC 394 ms
11,424 KB
testcase_33 AC 396 ms
11,248 KB
testcase_34 AC 395 ms
11,528 KB
testcase_35 AC 394 ms
11,224 KB
testcase_36 AC 386 ms
11,428 KB
testcase_37 AC 397 ms
11,216 KB
testcase_38 AC 389 ms
11,292 KB
testcase_39 AC 394 ms
11,248 KB
testcase_40 AC 396 ms
11,228 KB
testcase_41 AC 386 ms
11,188 KB
testcase_42 AC 395 ms
11,228 KB
testcase_43 AC 386 ms
11,236 KB
testcase_44 AC 403 ms
11,168 KB
testcase_45 AC 399 ms
11,236 KB
testcase_46 AC 403 ms
11,180 KB
testcase_47 AC 398 ms
11,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<long long int>> A(N,vector<long long int>(M));
  for(int i=0;i<N;i++) for(int j=0;j<M;j++) cin >> A[i][j];
  vector<vector<long long int>> dp(N+1,vector<long long int>(2,-1000000000000000000));
  dp[0][1] = 0;
  long long int ans = 0;
  for(int i=1;i<=N;i++){
    long long int S = 0;
    for(int j=0;j<M;j++) S += A[i-1][j];
    for(int j=0;j<i;j++) dp[i][0] = max(dp[i][0],dp[j][1]+S);
    for(int j=0;j<i;j++) dp[i][1] = max(dp[i][1],dp[j][0]-S);
    ans = max(ans,max(dp[i][0],dp[i][1]));
  }
  cout << ans << endl;
}
0