結果

問題 No.2730 Two Types Luggage
ユーザー otoshigootoshigo
提出日時 2024-04-19 21:30:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 269 ms / 2,000 ms
コード長 1,050 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 202,856 KB
実行使用メモリ 19,008 KB
最終ジャッジ日時 2024-04-19 21:30:20
合計ジャッジ時間 8,480 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,816 KB
testcase_03 AC 2 ms
6,816 KB
testcase_04 AC 5 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 8 ms
6,940 KB
testcase_11 AC 160 ms
14,948 KB
testcase_12 AC 267 ms
18,500 KB
testcase_13 AC 124 ms
12,528 KB
testcase_14 AC 151 ms
14,768 KB
testcase_15 AC 99 ms
6,944 KB
testcase_16 AC 55 ms
7,424 KB
testcase_17 AC 193 ms
18,080 KB
testcase_18 AC 175 ms
16,740 KB
testcase_19 AC 17 ms
6,940 KB
testcase_20 AC 72 ms
8,652 KB
testcase_21 AC 141 ms
14,176 KB
testcase_22 AC 196 ms
18,512 KB
testcase_23 AC 22 ms
6,944 KB
testcase_24 AC 86 ms
9,652 KB
testcase_25 AC 155 ms
14,976 KB
testcase_26 AC 42 ms
6,940 KB
testcase_27 AC 140 ms
14,140 KB
testcase_28 AC 78 ms
9,196 KB
testcase_29 AC 176 ms
16,924 KB
testcase_30 AC 77 ms
6,940 KB
testcase_31 AC 119 ms
12,280 KB
testcase_32 AC 103 ms
11,212 KB
testcase_33 AC 257 ms
19,000 KB
testcase_34 AC 264 ms
18,944 KB
testcase_35 AC 260 ms
19,008 KB
testcase_36 AC 269 ms
18,908 KB
testcase_37 AC 264 ms
18,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N,M;
    ll 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];
    ll ans=0;
    sort(rall(A));
    vector<ll>S(N+1);
    for(int i=0;i<N;i++)S[i+1]=S[i]+A[i];
    for(int bit=0;bit<1<<M;bit++){
        ll wt=0,cost=0;
        for(int i=0;i<M;i++){
            if(bit>>i&1){
                wt+=B[i];
                cost+=C[i];
            }
        }
        if(wt>W)continue;
        cost+=S[min((ll)N,W-wt)];
        chmax(ans,cost);
    }
    cout<<ans<<"\n";
}
0