結果

問題 No.2730 Two Types Luggage
ユーザー IchigoYPIchigoYP
提出日時 2024-04-19 23:43:36
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,720 bytes
コンパイル時間 3,702 ms
コンパイル使用メモリ 287,616 KB
実行使用メモリ 371,244 KB
最終ジャッジ日時 2024-04-19 23:43:54
合計ジャッジ時間 16,984 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 17 ms
21,384 KB
testcase_05 AC 3 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 6 ms
7,296 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 426 ms
18,128 KB
testcase_18 AC 391 ms
16,896 KB
testcase_19 AC 35 ms
5,376 KB
testcase_20 AC 178 ms
8,576 KB
testcase_21 AC 315 ms
14,336 KB
testcase_22 AC 469 ms
18,688 KB
testcase_23 AC 60 ms
22,644 KB
testcase_24 AC 190 ms
13,568 KB
testcase_25 AC 369 ms
14,976 KB
testcase_26 AC 94 ms
6,528 KB
testcase_27 AC 348 ms
15,104 KB
testcase_28 AC 169 ms
9,184 KB
testcase_29 AC 417 ms
16,916 KB
testcase_30 AC 324 ms
357,020 KB
testcase_31 AC 268 ms
12,440 KB
testcase_32 AC 235 ms
11,392 KB
testcase_33 AC 776 ms
371,240 KB
testcase_34 AC 788 ms
371,244 KB
testcase_35 AC 784 ms
371,188 KB
testcase_36 AC 826 ms
371,240 KB
testcase_37 AC 780 ms
371,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using vp = vector<pair<ll, ll>>;
#define mod 998244353
#define all(v) v.begin(), v.end()
#define resort(v) sort(v.rbegin(), v.rend())
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define per(i, n) for (ll i = n - 1; i >= 0; --i)
#define rep2(i, a, n) for (ll i = a; i < n; ++i)
#define per2(i, a, n) for (ll i = n - 1; i >= a; --i)
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
const ll inf = 1ll << 60;
ll dx[] = {1,0,0,-1,1,-1,1,-1};
ll dy[] = {0,1,-1,0,1,1,-1,-1};

int main() {
    ll n, m, w, ans = 0;
    cin >> n >> m >> w;
    vll a(n), b(m), c(m), s(n + 1);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    rep(i, m) cin >> c[i];
    resort(a);
    s[0] = 0;
    rep(i, n) s[i + 1] = s[i] + a[i];
    vvll dp(m + 1, vll(1ll << m));
    vvll dpw(m + 1, vll(1ll << m));
    rep(i, m){
        rep(j, (1ll << m)){
            chmax(dp[i + 1][j], dp[i][j]);
            if(dpw[i][j] + b[i] <= w) chmax(dp[i + 1][j | (1ll << i)], dp[i][j] + c[i]);
            dpw[i + 1][j] = dpw[i][j];
            dpw[i + 1][j | (1ll << i)] = dpw[i][j] + b[i];
        }
    }
    ans = s[n];
    rep(i, (1ll << m)){
        //cout << dpw[m][i] << endl;
        //cout << "i: " << i << endl; // デバッグ情報: i の値を出力
        if(dpw[m][i] > w) continue;
        if(w - dpw[m][i] >= 0 && w - dpw[m][i] < n) chmax(ans, dp[m][i] + s[w - dpw[m][i]]);
        else if(w - dpw[m][i] >= n) chmax(ans, dp[m][i] + s[n]);
        else chmax(ans, dp[m][i]);
    }
    cout << ans << endl;
}
0