結果

問題 No.2730 Two Types Luggage
ユーザー a01sa01toa01sa01to
提出日時 2024-04-22 00:20:47
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,648 ms / 2,000 ms
コード長 888 bytes
コンパイル時間 4,227 ms
コンパイル使用メモリ 291,360 KB
実行使用メモリ 84,684 KB
最終ジャッジ日時 2024-04-22 00:21:17
合計ジャッジ時間 25,327 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 11 ms
6,944 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 15 ms
6,940 KB
testcase_11 AC 369 ms
14,828 KB
testcase_12 AC 803 ms
23,564 KB
testcase_13 AC 272 ms
12,464 KB
testcase_14 AC 337 ms
14,888 KB
testcase_15 AC 441 ms
11,392 KB
testcase_16 AC 131 ms
7,936 KB
testcase_17 AC 429 ms
18,136 KB
testcase_18 AC 415 ms
16,932 KB
testcase_19 AC 37 ms
6,940 KB
testcase_20 AC 158 ms
8,740 KB
testcase_21 AC 324 ms
14,276 KB
testcase_22 AC 472 ms
18,388 KB
testcase_23 AC 73 ms
8,704 KB
testcase_24 AC 191 ms
10,776 KB
testcase_25 AC 340 ms
15,088 KB
testcase_26 AC 95 ms
6,944 KB
testcase_27 AC 343 ms
14,408 KB
testcase_28 AC 202 ms
9,136 KB
testcase_29 AC 417 ms
16,976 KB
testcase_30 AC 1,167 ms
70,144 KB
testcase_31 AC 275 ms
12,408 KB
testcase_32 AC 247 ms
11,360 KB
testcase_33 AC 1,648 ms
84,372 KB
testcase_34 AC 1,541 ms
84,684 KB
testcase_35 AC 1,462 ms
84,488 KB
testcase_36 AC 1,501 ms
84,352 KB
testcase_37 AC 1,465 ms
84,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  ll n, m, w;
  cin >> n >> m >> w;
  vector<ll> a(n), b(m), c(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  rep(i, m) cin >> c[i];
  map<ll, ll> mp;
  rep(bit, 1 << m) {
    ll wei = 0, val = 0;
    rep(i, m) {
      if (bit & (1 << i)) {
        wei += b[i];
        val += c[i];
      }
    }
    mp[wei] = max(mp[wei], val);
  }
  sort(a.rbegin(), a.rend());
  vector<ll> sum(n + 1, 0);
  rep(i, n) sum[i + 1] = sum[i] + a[i];
  ll ans = sum[min(n, w)];
  for (auto [wei, val] : mp) {
    if (wei > w) continue;
    ans = max(ans, sum[min(n, w - wei)] + val);
  }
  cout << ans << endl;
  return 0;
}
0