結果
| 問題 | 
                            No.2730 Two Types Luggage
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-04-19 21:58:26 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,240 bytes | 
| コンパイル時間 | 4,260 ms | 
| コンパイル使用メモリ | 232,700 KB | 
| 実行使用メモリ | 18,944 KB | 
| 最終ジャッジ日時 | 2024-10-11 15:04:19 | 
| 合計ジャッジ時間 | 15,674 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 7 WA * 28 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const vector<int> dx = {0,0,1,-1};
const vector<int> dy = {1,-1,0,0};
const ll INF = 1e18;
const ll inf = 1e8;
const ll MOD = 998244353;
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.rbegin(),a.rend());
    vector<ll> s(n);
    s[0] = a[0];
    for(int i = 1; i < n; i++) s[i] = s[i-1] + a[i];
    ll ans = -1;
    
    for(int bit = 0; bit < (1<<m); bit++){
        vector<int> t;
        for(int i = 0; i < m; i++){
            if(bit & (1<<i) == 1) t.push_back(i);
        }
        ll q = w, v = 0;
        for(auto x : t){
            q -= b[x];
            v += c[x];
        }
        if(q < 0) break;
        if(q > n) v += s[n-1];
        else v += s[q-1];
        chmax(ans,v);
    }
    cout << ans << endl;
}