結果

問題 No.974 最後の日までに
ユーザー utouto97utouto97
提出日時 2020-01-21 22:12:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,201 bytes
コンパイル時間 2,360 ms
コンパイル使用メモリ 152,284 KB
実行使用メモリ 15,096 KB
最終ジャッジ日時 2023-09-20 13:24:39
合計ジャッジ時間 5,495 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
12,424 KB
testcase_01 AC 52 ms
12,592 KB
testcase_02 AC 52 ms
14,912 KB
testcase_03 AC 52 ms
12,356 KB
testcase_04 AC 52 ms
13,000 KB
testcase_05 AC 51 ms
12,924 KB
testcase_06 AC 52 ms
12,808 KB
testcase_07 AC 53 ms
12,292 KB
testcase_08 AC 52 ms
13,580 KB
testcase_09 AC 53 ms
13,308 KB
testcase_10 AC 53 ms
12,740 KB
testcase_11 AC 54 ms
13,200 KB
testcase_12 AC 53 ms
12,348 KB
testcase_13 AC 54 ms
13,616 KB
testcase_14 AC 54 ms
14,868 KB
testcase_15 AC 53 ms
12,396 KB
testcase_16 WA -
testcase_17 AC 59 ms
12,296 KB
testcase_18 AC 60 ms
12,080 KB
testcase_19 AC 61 ms
14,680 KB
testcase_20 AC 60 ms
12,084 KB
testcase_21 AC 59 ms
12,936 KB
testcase_22 AC 62 ms
15,096 KB
testcase_23 WA -
testcase_24 AC 61 ms
12,980 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 55 ms
13,708 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 59 ms
14,424 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 34 ms
8,144 KB
testcase_34 AC 58 ms
13,004 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 40 ms
10,324 KB
testcase_41 AC 49 ms
13,788 KB
testcase_42 WA -
testcase_43 AC 61 ms
13,396 KB
testcase_44 WA -
testcase_45 AC 38 ms
8,172 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

int w, a[55], b[55], c[55];

void dfs(int i, int n, int money, int like, vector<P> &v){
  if(i == n){
    v.emplace_back(money, like);
    return;
  }

  dfs(i+1, n, money+a[i], like, v);
  if(i+1 < n) dfs(i+2, n, money-c[i+1], like+b[i+1], v);
}

int solve(int half){
  vector<P> x, y;
  dfs(0, half, 0, 0, x);
  dfs(half, w, 0, 0, y);

  sort(all(x)); sort(all(y));

  int ma = -1e15;
  for(auto i = x.rbegin(); i != x.rend(); i++){
    chmax(ma, i->second);
    chmax(i->second, ma);
  }

  int ans = 0;
  for(auto i : y){
    auto j = lower_bound(all(x), P(-i.first, 0LL));
    if(j == x.end()) continue;
    chmax(ans, j->second + i.second);
  }

  return ans;
}

signed main() {
  cin >> w;
  rep(i, 0, w) cin >> a[i] >> b[i] >> c[i];

  cout << solve(w/2) << endl;

  return 0;
}
0