結果

問題 No.2730 Two Types Luggage
ユーザー ococonomy1ococonomy1
提出日時 2024-04-19 21:27:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 318 ms / 2,000 ms
コード長 2,336 bytes
コンパイル時間 1,409 ms
コンパイル使用メモリ 115,464 KB
実行使用メモリ 18,816 KB
最終ジャッジ日時 2024-04-19 21:28:10
合計ジャッジ時間 8,488 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 3 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 177 ms
14,848 KB
testcase_12 AC 304 ms
18,528 KB
testcase_13 AC 139 ms
12,576 KB
testcase_14 AC 175 ms
14,848 KB
testcase_15 AC 115 ms
6,144 KB
testcase_16 AC 65 ms
7,296 KB
testcase_17 AC 223 ms
18,048 KB
testcase_18 AC 204 ms
16,896 KB
testcase_19 AC 19 ms
5,376 KB
testcase_20 AC 82 ms
8,480 KB
testcase_21 AC 166 ms
14,284 KB
testcase_22 AC 230 ms
18,560 KB
testcase_23 AC 26 ms
5,376 KB
testcase_24 AC 97 ms
9,728 KB
testcase_25 AC 183 ms
14,976 KB
testcase_26 AC 50 ms
6,400 KB
testcase_27 AC 167 ms
14,080 KB
testcase_28 AC 90 ms
9,216 KB
testcase_29 AC 208 ms
16,896 KB
testcase_30 AC 91 ms
5,376 KB
testcase_31 AC 136 ms
12,416 KB
testcase_32 AC 122 ms
11,392 KB
testcase_33 AC 304 ms
18,816 KB
testcase_34 AC 305 ms
18,808 KB
testcase_35 AC 318 ms
18,688 KB
testcase_36 AC 305 ms
18,816 KB
testcase_37 AC 312 ms
18,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
//#define AMARI 1000000007
#define el '\n'
#define El '\n'

#define MULTI_TEST_CASE false
void solve(void){
    //問題を見たらまず「この問題設定から言えること」をいっぱい言う
    //一個回答に繋がりそうな解法が見えても、実装や細かい詰めに時間がかかりそうなら別の方針を考えてみる
    //添え字回りで面倒になりそうなときは楽になる言い換えを実装の前にじっくり考える
    //ある程度考察しても全然取っ掛かりが見えないときは実験をしてみる
    //よりシンプルな問題に言い換えられたら、言い換えた先の問題を自然言語ではっきりと書く
    int n,m;
    cin >> n >> m;
    ll w;
    cin >> w;
    vector<ll> a(n),b(m),c(m);
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a.rbegin(),a.rend());
    vector<ll> ruiseki(n + 1,0);
    for(int i = 0; i < n; i++){
        ruiseki[i + 1] = ruiseki[i] + a[i];
    }
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    for(int i = 0; i < m; i++)cin >> c[i];

    int ni = (1LL << m);
    ll ans = 0;
    for(int S = 0; S < ni; S++){
        ll temp_weight = 0;
        ll temp_val = 0;
        for(int j = 0; j < m; j++){
            if((S & (1 << j))){
                temp_weight += b[j];
                temp_val += c[j];
            }
        }
        if(temp_weight > w)continue;
        ll idx = w - temp_weight;
        temp_val += ruiseki[min(idx,(ll)n)];
        ans = max(ans,temp_val);
    }
    cout << ans << el;
    return;
}

void calc(void){
    return;
}

signed main(void){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if(MULTI_TEST_CASE)cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
0