結果

問題 No.2730 Two Types Luggage
ユーザー soldraysoldray
提出日時 2024-04-20 00:01:31
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 474 ms / 2,000 ms
コード長 906 bytes
コンパイル時間 2,336 ms
コンパイル使用メモリ 164,588 KB
実行使用メモリ 18,932 KB
最終ジャッジ日時 2024-04-20 00:01:44
合計ジャッジ時間 13,038 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,816 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 15 ms
6,940 KB
testcase_11 AC 319 ms
14,708 KB
testcase_12 AC 474 ms
18,436 KB
testcase_13 AC 261 ms
12,332 KB
testcase_14 AC 331 ms
14,892 KB
testcase_15 AC 104 ms
6,940 KB
testcase_16 AC 118 ms
7,484 KB
testcase_17 AC 434 ms
17,936 KB
testcase_18 AC 377 ms
16,808 KB
testcase_19 AC 33 ms
6,940 KB
testcase_20 AC 149 ms
8,716 KB
testcase_21 AC 303 ms
14,156 KB
testcase_22 AC 448 ms
18,376 KB
testcase_23 AC 40 ms
6,944 KB
testcase_24 AC 180 ms
9,540 KB
testcase_25 AC 327 ms
14,952 KB
testcase_26 AC 94 ms
6,940 KB
testcase_27 AC 300 ms
14,192 KB
testcase_28 AC 166 ms
9,164 KB
testcase_29 AC 403 ms
16,900 KB
testcase_30 AC 59 ms
6,940 KB
testcase_31 AC 252 ms
12,340 KB
testcase_32 AC 223 ms
11,340 KB
testcase_33 AC 449 ms
18,932 KB
testcase_34 AC 455 ms
18,708 KB
testcase_35 AC 467 ms
18,776 KB
testcase_36 AC 463 ms
18,752 KB
testcase_37 AC 449 ms
18,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

#define yn(pope) (pope ? "Yes" : "No")

#define rep(i, n, m) for (int i = (n); i < (m); i++)
#define rrep(i, n, m) for (int i = (n); i > m; i--)

#define IINF (1 << 30)
#define INF (1ll << 60)

#define all(v) v.begin(), v.end()

int main() {
  int N, M;
  i64 W; cin >> N >> M >> W;

  vector<i64> A(N), B(M), C(M);

  for (i64 &x : A) { cin >> x; }
  for (i64 &x : B) { cin >> x; }
  for (i64 &x : C) { cin >> x; }

  sort(all(A));
  reverse(all(A));

  vector<i64> sum(N + 1);

  rep(i, 1, N + 1) {
    sum[i] = sum[i - 1] + A[i - 1];
  }

  i64 ans = 0;

  rep(i, 0, (1 << M)) {
    i64 w = 0;
    i64 v = 0;

    rep(j, 0, M) {
      w += B[j] * ((i >> j) & 1);
      v += C[j] * ((i >> j) & 1);
    }

    v += sum[max(0ll, min((i64)N, W - w))];

    if (w <= W) { ans = max(ans, v); }
  }

  cout << ans << endl;

  return 0;
}
0