結果

問題 No.2730 Two Types Luggage
ユーザー kokoseikokosei
提出日時 2024-04-19 21:32:24
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 271 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 896 ms
コンパイル使用メモリ 99,480 KB
実行使用メモリ 11,324 KB
最終ジャッジ日時 2024-04-19 21:32:37
合計ジャッジ時間 7,306 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 5 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 8 ms
6,940 KB
testcase_11 AC 152 ms
10,228 KB
testcase_12 AC 264 ms
11,312 KB
testcase_13 AC 119 ms
8,928 KB
testcase_14 AC 153 ms
9,908 KB
testcase_15 AC 102 ms
6,944 KB
testcase_16 AC 61 ms
6,944 KB
testcase_17 AC 220 ms
11,016 KB
testcase_18 AC 178 ms
10,484 KB
testcase_19 AC 17 ms
6,944 KB
testcase_20 AC 70 ms
6,944 KB
testcase_21 AC 143 ms
10,224 KB
testcase_22 AC 206 ms
10,984 KB
testcase_23 AC 23 ms
6,944 KB
testcase_24 AC 86 ms
8,368 KB
testcase_25 AC 155 ms
9,920 KB
testcase_26 AC 43 ms
6,944 KB
testcase_27 AC 144 ms
9,516 KB
testcase_28 AC 77 ms
7,820 KB
testcase_29 AC 184 ms
10,504 KB
testcase_30 AC 82 ms
6,944 KB
testcase_31 AC 117 ms
9,188 KB
testcase_32 AC 107 ms
9,676 KB
testcase_33 AC 266 ms
11,324 KB
testcase_34 AC 268 ms
11,324 KB
testcase_35 AC 270 ms
11,264 KB
testcase_36 AC 271 ms
11,196 KB
testcase_37 AC 269 ms
11,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int N, M;
ll W;
ll A[1010101];
ll B[20], C[20];
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> N >> M >> W;
    for(int i = 1;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, A + N + 1);
    reverse(A + 1, A + N + 1);
    for(int i = 0;i < N;i++){
        A[i + 1] += A[i];
    }
    ll ans = 0;
    for(int i = 0;i < (1 << M);i++){
        ll v = 0, w = 0;
        for(int j = 0;j < M;j++){
            if(i >> j & 1)continue;
            w += B[j];
            v += C[j];
        }
        if(w > W)continue;
        ans = max(ans, v + A[min((ll)N, W - w)]);
    }
    cout << ans << endl;
    return 0;
}
0