結果

問題 No.2730 Two Types Luggage
ユーザー tobbietobbie
提出日時 2024-04-21 22:57:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,511 ms / 2,000 ms
コード長 821 bytes
コンパイル時間 2,065 ms
コンパイル使用メモリ 175,896 KB
実行使用メモリ 69,852 KB
最終ジャッジ日時 2024-04-21 22:57:37
合計ジャッジ時間 30,039 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 7 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 30 ms
5,504 KB
testcase_11 AC 850 ms
52,864 KB
testcase_12 AC 1,197 ms
68,768 KB
testcase_13 AC 647 ms
42,624 KB
testcase_14 AC 846 ms
52,712 KB
testcase_15 AC 264 ms
16,000 KB
testcase_16 AC 309 ms
21,248 KB
testcase_17 AC 1,070 ms
66,304 KB
testcase_18 AC 984 ms
61,208 KB
testcase_19 AC 74 ms
8,320 KB
testcase_20 AC 373 ms
26,240 KB
testcase_21 AC 772 ms
49,664 KB
testcase_22 AC 1,111 ms
68,352 KB
testcase_23 AC 105 ms
9,216 KB
testcase_24 AC 450 ms
30,464 KB
testcase_25 AC 845 ms
53,376 KB
testcase_26 AC 213 ms
16,896 KB
testcase_27 AC 771 ms
49,784 KB
testcase_28 AC 434 ms
28,544 KB
testcase_29 AC 980 ms
61,440 KB
testcase_30 AC 382 ms
9,216 KB
testcase_31 AC 635 ms
41,808 KB
testcase_32 AC 584 ms
37,632 KB
testcase_33 AC 1,496 ms
69,572 KB
testcase_34 AC 1,500 ms
69,760 KB
testcase_35 AC 1,504 ms
69,632 KB
testcase_36 AC 1,506 ms
69,564 KB
testcase_37 AC 1,511 ms
69,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, n) for (int i = 0; i < (int)n; i++)
using ll = long long int;

bool comp(int a, int b) {
  return a > b;
}

int main() {
  int N, M;
  ll W;
  cin >> N >> M >> W;
  vector<int> 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> dp;
  sort(A.begin(), A.end(), comp);
  rep(i, N) {
    if (i + 1 <= W)
      dp[i + 1] = dp[i] + A[i];
    else
      dp[i + 1] = dp[i];
  }
  ll val = dp[N];
  rep(i, (1<<M)) {
    ll bsum = 0, csum = 0;
    rep(j, M) {
      if (i & (1<<j)) {
	bsum += B[j];
	csum += C[j];
      }
    }
    if (bsum > W)
      continue;
    if (W - bsum > N)
      val = max(csum + dp[N], val);
    else
      val = max(csum + dp[W - bsum], val);
  }
  cout << val << endl;
  return 0;
}
0