結果

問題 No.2730 Two Types Luggage
ユーザー rerurenairerurenai
提出日時 2024-04-19 22:32:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 550 ms / 2,000 ms
コード長 1,376 bytes
コンパイル時間 4,545 ms
コンパイル使用メモリ 227,656 KB
実行使用メモリ 18,944 KB
最終ジャッジ日時 2024-04-19 22:32:35
合計ジャッジ時間 14,803 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 6 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 15 ms
5,376 KB
testcase_11 AC 349 ms
14,848 KB
testcase_12 AC 463 ms
18,688 KB
testcase_13 AC 274 ms
12,416 KB
testcase_14 AC 344 ms
14,976 KB
testcase_15 AC 89 ms
6,272 KB
testcase_16 AC 126 ms
7,680 KB
testcase_17 AC 442 ms
18,048 KB
testcase_18 AC 399 ms
16,896 KB
testcase_19 AC 35 ms
5,376 KB
testcase_20 AC 159 ms
8,704 KB
testcase_21 AC 318 ms
14,256 KB
testcase_22 AC 457 ms
18,560 KB
testcase_23 AC 44 ms
5,376 KB
testcase_24 AC 188 ms
9,728 KB
testcase_25 AC 345 ms
15,104 KB
testcase_26 AC 94 ms
6,400 KB
testcase_27 AC 316 ms
14,204 KB
testcase_28 AC 174 ms
9,344 KB
testcase_29 AC 407 ms
16,896 KB
testcase_30 AC 106 ms
5,376 KB
testcase_31 AC 262 ms
12,416 KB
testcase_32 AC 235 ms
11,392 KB
testcase_33 AC 518 ms
18,944 KB
testcase_34 AC 518 ms
18,816 KB
testcase_35 AC 550 ms
18,944 KB
testcase_36 AC 518 ms
18,816 KB
testcase_37 AC 526 ms
18,828 KB
権限があれば一括ダウンロードができます

ソースコード

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)
    {
        ll p = w, v = 0;
        for (int i = 0; i < m; ++i) {
            if (bit & (1 << i)) { 
                p -= b[i];
                v += c[i];
            }
        }
        
        if(p<0) break;
        
        if(p>=n){
            v += s[n-1];
        }else if(p==0){
            ;
        } else{
            v += s[p-1];
        }
        if(v == 127){
            cout << p << endl;
            return 0;
        }

        chmax(ans,v);
		
    }
   
    cout << ans << endl;
}
0