結果

問題 No.1199 お菓子配り-2
ユーザー chocono2230chocono2230
提出日時 2020-08-28 21:58:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 402 ms / 1,000 ms
コード長 1,056 bytes
コンパイル時間 2,006 ms
コンパイル使用メモリ 168,196 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-08 22:40:52
合計ジャッジ時間 16,752 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 100 ms
4,380 KB
testcase_04 AC 250 ms
4,380 KB
testcase_05 AC 9 ms
4,384 KB
testcase_06 AC 15 ms
4,380 KB
testcase_07 AC 121 ms
4,380 KB
testcase_08 AC 167 ms
4,380 KB
testcase_09 AC 101 ms
4,376 KB
testcase_10 AC 26 ms
4,376 KB
testcase_11 AC 78 ms
4,376 KB
testcase_12 AC 77 ms
4,380 KB
testcase_13 AC 27 ms
4,380 KB
testcase_14 AC 22 ms
4,376 KB
testcase_15 AC 19 ms
4,380 KB
testcase_16 AC 162 ms
4,380 KB
testcase_17 AC 78 ms
4,380 KB
testcase_18 AC 169 ms
4,380 KB
testcase_19 AC 45 ms
4,380 KB
testcase_20 AC 303 ms
4,376 KB
testcase_21 AC 186 ms
4,380 KB
testcase_22 AC 98 ms
4,376 KB
testcase_23 AC 136 ms
4,376 KB
testcase_24 AC 187 ms
4,380 KB
testcase_25 AC 29 ms
4,380 KB
testcase_26 AC 211 ms
4,380 KB
testcase_27 AC 170 ms
4,376 KB
testcase_28 AC 399 ms
4,380 KB
testcase_29 AC 399 ms
4,380 KB
testcase_30 AC 399 ms
4,376 KB
testcase_31 AC 402 ms
4,380 KB
testcase_32 AC 400 ms
4,376 KB
testcase_33 AC 399 ms
4,380 KB
testcase_34 AC 400 ms
4,376 KB
testcase_35 AC 399 ms
4,380 KB
testcase_36 AC 400 ms
4,380 KB
testcase_37 AC 397 ms
4,384 KB
testcase_38 AC 399 ms
4,380 KB
testcase_39 AC 399 ms
4,380 KB
testcase_40 AC 399 ms
4,380 KB
testcase_41 AC 399 ms
4,376 KB
testcase_42 AC 399 ms
4,380 KB
testcase_43 AC 399 ms
4,376 KB
testcase_44 AC 399 ms
4,380 KB
testcase_45 AC 399 ms
4,380 KB
testcase_46 AC 399 ms
4,380 KB
testcase_47 AC 398 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<ll> a(n, 0);
  rep(i, n)rep(j, m){
    ll in;
    cin >> in;
    a.at(i) += in;
  }
  a.push_back(0);
  ll ans = 0;
  rep(i, n){
    ll add = a.at(i);
    bool mode = false;
    ll bf = -1;
    rep2(j, i+1, n){
      if(mode == false){
        if(a.at(j) < a.at(j+1)){
          bf = a.at(j);
          mode = true;
        }
      }else{
        if(a.at(j) > a.at(j+1)){
          add += a.at(j) - bf;
          mode = false;
        }
      }
    }
    ans = max(ans, add);
  }
  cout << ans << endl;
  return 0;
}
0