結果

問題 No.2730 Two Types Luggage
ユーザー haihamabossuhaihamabossu
提出日時 2024-04-19 21:34:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 272 ms / 2,000 ms
コード長 857 bytes
コンパイル時間 2,177 ms
コンパイル使用メモリ 203,464 KB
実行使用メモリ 18,872 KB
最終ジャッジ日時 2024-04-19 21:34:48
合計ジャッジ時間 8,354 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 5 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 7 ms
6,944 KB
testcase_11 AC 152 ms
14,724 KB
testcase_12 AC 261 ms
18,660 KB
testcase_13 AC 120 ms
12,464 KB
testcase_14 AC 154 ms
14,768 KB
testcase_15 AC 97 ms
6,944 KB
testcase_16 AC 56 ms
7,424 KB
testcase_17 AC 197 ms
18,180 KB
testcase_18 AC 177 ms
16,920 KB
testcase_19 AC 16 ms
6,944 KB
testcase_20 AC 70 ms
8,536 KB
testcase_21 AC 140 ms
14,252 KB
testcase_22 AC 200 ms
18,576 KB
testcase_23 AC 22 ms
6,940 KB
testcase_24 AC 87 ms
9,592 KB
testcase_25 AC 152 ms
14,976 KB
testcase_26 AC 43 ms
6,940 KB
testcase_27 AC 142 ms
14,040 KB
testcase_28 AC 79 ms
9,152 KB
testcase_29 AC 180 ms
16,920 KB
testcase_30 AC 77 ms
6,940 KB
testcase_31 AC 116 ms
12,260 KB
testcase_32 AC 109 ms
11,216 KB
testcase_33 AC 272 ms
18,848 KB
testcase_34 AC 265 ms
18,848 KB
testcase_35 AC 260 ms
18,832 KB
testcase_36 AC 254 ms
18,728 KB
testcase_37 AC 261 ms
18,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void solve() {
  ll n, m, w;
  cin >> n >> m >> w;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> b(m);
  rep(i, m) cin >> b[i];
  vector<ll> c(m);
  rep(i, m) cin >> c[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  vector<ll> sum(n + 1);
  rep(i, n) sum[i + 1] = sum[i] + a[i];
  ll ans = 0;
  rep(S, 1 << m) {
    ll now_b = 0, now_c = 0;
    rep(mi, m) if ((S >> mi) & 1) {
      now_b += b[mi];
      now_c += c[mi];
    }
    if (now_b <= w) {
      now_c += sum[min(n, w - now_b)];
      ans = max(ans, now_c);
    }
  }
  cout << ans << '\n';
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int T = 1;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}
0