結果

問題 No.2730 Two Types Luggage
ユーザー FplusFplusFFplusFplusF
提出日時 2024-04-05 11:06:10
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 2,974 ms
コンパイル使用メモリ 252,460 KB
実行使用メモリ 18,764 KB
最終ジャッジ日時 2024-04-05 11:06:20
合計ジャッジ時間 9,396 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 74 ms
6,676 KB
testcase_05 AC 18 ms
6,676 KB
testcase_06 AC 19 ms
6,676 KB
testcase_07 AC 37 ms
6,676 KB
testcase_08 AC 73 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 174 ms
17,140 KB
testcase_11 AC 215 ms
18,516 KB
testcase_12 AC 26 ms
6,676 KB
testcase_13 AC 94 ms
10,696 KB
testcase_14 AC 231 ms
18,764 KB
testcase_15 AC 75 ms
9,216 KB
testcase_16 AC 43 ms
6,676 KB
testcase_17 AC 27 ms
6,676 KB
testcase_18 AC 32 ms
6,676 KB
testcase_19 AC 55 ms
7,680 KB
testcase_20 AC 42 ms
6,676 KB
testcase_21 AC 29 ms
6,676 KB
testcase_22 AC 99 ms
6,676 KB
testcase_23 AC 39 ms
6,676 KB
testcase_24 AC 212 ms
17,228 KB
testcase_25 AC 110 ms
11,632 KB
testcase_26 AC 20 ms
6,676 KB
testcase_27 AC 94 ms
10,672 KB
testcase_28 AC 39 ms
6,676 KB
testcase_29 AC 167 ms
16,312 KB
testcase_30 AC 180 ms
17,360 KB
testcase_31 AC 74 ms
9,180 KB
testcase_32 AC 136 ms
14,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,m,sz;
    cin >> n >> m >> sz;
    vector<ll> a(n),b(m),c(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    rep(i,m) cin >> c[i];
    sort(all(a));
    reverse(all(a));
    vector<ll> sum(n+1,0);
    rep(i,n) sum[i+1]=sum[i]+a[i];
    ll ans=0;
    rep(i,1<<m){
        ll w=0,v=0;
        rep(j,m){
            if(i&1<<j){
                w+=b[j];
                v+=c[j];
            }
        }
        ll x=sz-w;
        if(x<0) continue;
        chmax(ans,v+sum[min(n,x)]);
    }
    cout << ans << '\n';
}
0