結果

問題 No.974 最後の日までに
ユーザー risujirohrisujiroh
提出日時 2020-01-17 22:37:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 804 bytes
コンパイル時間 1,824 ms
コンパイル使用メモリ 167,320 KB
実行使用メモリ 5,316 KB
最終ジャッジ日時 2023-09-08 05:01:22
合計ジャッジ時間 7,709 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 1 ms
4,380 KB
testcase_30 RE -
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 RE -
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> a(n), b(n), c(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  long long s = accumulate(begin(a), end(a), 0LL);
  assert(n <= 24);
  long long res = 0;
  for (int bt = 0; bt < 1 << n; bt += 2) {
    bool ok = true;
    for (int i = 1; i < n; ++i) {
      if (bt >> i & 1 and bt >> (i - 1) & 1) {
        ok = false;
        break;
      }
    }
    if (not ok) {
      continue;
    }
    long long sw = 0, sv = 0;
    for (int i = 0; i < n; ++i) {
      if (bt >> i & 1) {
        sw += a[i - 1] + a[i] + c[i];
        sv += b[i];
      }
    }
    if (sw <= s) {
      res = max(res, sv);
    }
  }
  cout << res << '\n';
}
0