結果

問題 No.2730 Two Types Luggage
ユーザー pia-19pia-19
提出日時 2024-04-19 22:01:58
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 551 ms / 2,000 ms
コード長 1,074 bytes
コンパイル時間 3,448 ms
コンパイル使用メモリ 280,724 KB
実行使用メモリ 18,944 KB
最終ジャッジ日時 2024-04-19 22:02:23
合計ジャッジ時間 14,293 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 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 15 ms
5,376 KB
testcase_11 AC 371 ms
14,900 KB
testcase_12 AC 452 ms
18,688 KB
testcase_13 AC 271 ms
12,436 KB
testcase_14 AC 340 ms
14,948 KB
testcase_15 AC 93 ms
6,272 KB
testcase_16 AC 132 ms
7,424 KB
testcase_17 AC 435 ms
18,048 KB
testcase_18 AC 426 ms
16,896 KB
testcase_19 AC 35 ms
5,376 KB
testcase_20 AC 161 ms
8,576 KB
testcase_21 AC 316 ms
14,116 KB
testcase_22 AC 445 ms
18,560 KB
testcase_23 AC 48 ms
5,376 KB
testcase_24 AC 184 ms
9,564 KB
testcase_25 AC 367 ms
15,104 KB
testcase_26 AC 94 ms
6,400 KB
testcase_27 AC 321 ms
14,328 KB
testcase_28 AC 174 ms
9,344 KB
testcase_29 AC 401 ms
16,896 KB
testcase_30 AC 120 ms
5,376 KB
testcase_31 AC 260 ms
12,400 KB
testcase_32 AC 239 ms
11,300 KB
testcase_33 AC 545 ms
18,944 KB
testcase_34 AC 532 ms
18,816 KB
testcase_35 AC 533 ms
18,816 KB
testcase_36 AC 537 ms
18,944 KB
testcase_37 AC 551 ms
18,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int INF = 1<<30;
const int MOD = 998244353;
//const long long INF = 1LL<<60;
using graph = vector<vector<int>>;
using ll = long long;


int main(){
    ll n, m, w;
    cin >> n >> m >> w;
    vector<ll> a(n), b(m), c(m);
    for (int i=0; i < n; i++) cin >> a[i];
    for (int i=0; i < m; i++) cin >> b[i];
    for (int i=0; i < m; i++) cin >> c[i];
    sort(a.begin(), a.end(), greater<ll>());
    vector<ll> acc_a(n+1);
    for (int i=1; i < n+1; i++) acc_a[i] = acc_a[i-1] + a[i-1];

    
    ll ans = 0LL;
    for (int i=0; i < (1<<m); i++){
        ll weight = 0;
        ll value = 0;
        bool flag = true;
        for (int j=0; j < m; j++){
            if (i & (1<<j)){
                weight += b[j];
                value += c[j];
            }
            if (weight > w){
                flag = false;
                break;
            }
        }
        
        if (flag){
            ll rem = w - weight;
            ans = max(ans, value + acc_a[min(n, rem)]);
        }
    }
    cout << ans << endl;
}
0