結果

問題 No.1199 お菓子配り-2
ユーザー chocono2230chocono2230
提出日時 2020-08-28 21:58:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 417 ms / 1,000 ms
コード長 1,056 bytes
コンパイル時間 1,906 ms
コンパイル使用メモリ 166,280 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 14:50:52
合計ジャッジ時間 16,863 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 107 ms
5,376 KB
testcase_04 AC 262 ms
5,376 KB
testcase_05 AC 9 ms
5,376 KB
testcase_06 AC 15 ms
5,376 KB
testcase_07 AC 119 ms
5,376 KB
testcase_08 AC 167 ms
5,376 KB
testcase_09 AC 101 ms
5,376 KB
testcase_10 AC 26 ms
5,376 KB
testcase_11 AC 76 ms
5,376 KB
testcase_12 AC 79 ms
5,376 KB
testcase_13 AC 26 ms
5,376 KB
testcase_14 AC 23 ms
5,376 KB
testcase_15 AC 19 ms
5,376 KB
testcase_16 AC 167 ms
5,376 KB
testcase_17 AC 77 ms
5,376 KB
testcase_18 AC 168 ms
5,376 KB
testcase_19 AC 45 ms
5,376 KB
testcase_20 AC 308 ms
5,376 KB
testcase_21 AC 188 ms
5,376 KB
testcase_22 AC 98 ms
5,376 KB
testcase_23 AC 137 ms
5,376 KB
testcase_24 AC 184 ms
5,376 KB
testcase_25 AC 28 ms
5,376 KB
testcase_26 AC 210 ms
5,376 KB
testcase_27 AC 173 ms
5,376 KB
testcase_28 AC 398 ms
5,376 KB
testcase_29 AC 395 ms
5,376 KB
testcase_30 AC 407 ms
5,376 KB
testcase_31 AC 396 ms
5,376 KB
testcase_32 AC 410 ms
5,376 KB
testcase_33 AC 410 ms
5,376 KB
testcase_34 AC 407 ms
5,376 KB
testcase_35 AC 401 ms
5,376 KB
testcase_36 AC 401 ms
5,376 KB
testcase_37 AC 404 ms
5,376 KB
testcase_38 AC 405 ms
5,376 KB
testcase_39 AC 417 ms
5,376 KB
testcase_40 AC 402 ms
5,376 KB
testcase_41 AC 399 ms
5,376 KB
testcase_42 AC 403 ms
5,376 KB
testcase_43 AC 398 ms
5,376 KB
testcase_44 AC 401 ms
5,376 KB
testcase_45 AC 401 ms
5,376 KB
testcase_46 AC 401 ms
5,376 KB
testcase_47 AC 405 ms
5,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