結果

問題 No.2730 Two Types Luggage
ユーザー IchigoYPIchigoYP
提出日時 2024-04-19 23:59:35
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 872 ms / 2,000 ms
コード長 1,507 bytes
コンパイル時間 3,505 ms
コンパイル使用メモリ 286,064 KB
実行使用メモリ 35,328 KB
最終ジャッジ日時 2024-04-19 23:59:55
合計ジャッジ時間 17,475 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 21 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 16 ms
5,376 KB
testcase_11 AC 347 ms
14,848 KB
testcase_12 AC 848 ms
34,972 KB
testcase_13 AC 284 ms
12,416 KB
testcase_14 AC 384 ms
14,848 KB
testcase_15 AC 426 ms
22,656 KB
testcase_16 AC 141 ms
7,552 KB
testcase_17 AC 451 ms
18,048 KB
testcase_18 AC 455 ms
16,896 KB
testcase_19 AC 37 ms
5,376 KB
testcase_20 AC 188 ms
8,576 KB
testcase_21 AC 351 ms
14,268 KB
testcase_22 AC 495 ms
18,572 KB
testcase_23 AC 66 ms
5,632 KB
testcase_24 AC 197 ms
9,968 KB
testcase_25 AC 360 ms
15,064 KB
testcase_26 AC 104 ms
6,528 KB
testcase_27 AC 333 ms
14,252 KB
testcase_28 AC 195 ms
9,216 KB
testcase_29 AC 426 ms
16,892 KB
testcase_30 AC 364 ms
20,992 KB
testcase_31 AC 272 ms
12,288 KB
testcase_32 AC 261 ms
11,392 KB
testcase_33 AC 788 ms
35,200 KB
testcase_34 AC 872 ms
35,200 KB
testcase_35 AC 828 ms
35,328 KB
testcase_36 AC 821 ms
35,200 KB
testcase_37 AC 796 ms
35,328 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];
    vll dp(1ll << m);
    vll dpw(1ll << m);
    rep(i,1ll<<m){
        rep(j,m){
            if((i/(1ll<<j))%2){
                dp[i] += c[j];
                dpw[i] += b[j];
            } 
        }
        //cout << dp[i] << " " << dpw[i] << endl;
    }
    if(n<w) ans = s[n];
    else ans = s[w];
    rep(i, (1ll << m)){
        if(dpw[i] > w) continue;
        if(w - dpw[i] >= 0 && w - dpw[i] < n) chmax(ans, dp[i] + s[w - dpw[i]]);
        else if(w - dpw[i] >= n) chmax(ans, dp[i] + s[n]);
        else chmax(ans, dp[i]);
    }
    cout << ans << endl;
}
0