結果

問題 No.2730 Two Types Luggage
ユーザー rerurenairerurenai
提出日時 2024-04-19 21:58:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,240 bytes
コンパイル時間 4,159 ms
コンパイル使用メモリ 229,540 KB
実行使用メモリ 19,144 KB
最終ジャッジ日時 2024-04-19 21:58:48
合計ジャッジ時間 15,460 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 17 ms
5,376 KB
testcase_11 AC 393 ms
14,928 KB
testcase_12 AC 485 ms
18,608 KB
testcase_13 AC 291 ms
12,456 KB
testcase_14 AC 371 ms
14,976 KB
testcase_15 AC 93 ms
6,400 KB
testcase_16 AC 134 ms
7,424 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0