結果

問題 No.2730 Two Types Luggage
ユーザー Dương Nguyễn CảnhDương Nguyễn Cảnh
提出日時 2024-04-19 21:31:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 1,812 bytes
コンパイル時間 2,408 ms
コンパイル使用メモリ 203,832 KB
実行使用メモリ 15,020 KB
最終ジャッジ日時 2024-04-19 21:32:08
合計ジャッジ時間 8,268 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 5 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 7 ms
6,944 KB
testcase_11 AC 146 ms
12,028 KB
testcase_12 AC 251 ms
14,728 KB
testcase_13 AC 114 ms
10,180 KB
testcase_14 AC 165 ms
12,008 KB
testcase_15 AC 101 ms
6,940 KB
testcase_16 AC 54 ms
6,940 KB
testcase_17 AC 188 ms
14,416 KB
testcase_18 AC 173 ms
13,436 KB
testcase_19 AC 16 ms
6,944 KB
testcase_20 AC 68 ms
7,248 KB
testcase_21 AC 138 ms
11,392 KB
testcase_22 AC 197 ms
14,828 KB
testcase_23 AC 22 ms
6,944 KB
testcase_24 AC 81 ms
8,092 KB
testcase_25 AC 150 ms
12,012 KB
testcase_26 AC 42 ms
6,940 KB
testcase_27 AC 141 ms
11,312 KB
testcase_28 AC 74 ms
7,656 KB
testcase_29 AC 173 ms
13,348 KB
testcase_30 AC 79 ms
6,944 KB
testcase_31 AC 129 ms
9,856 KB
testcase_32 AC 105 ms
9,348 KB
testcase_33 AC 274 ms
14,960 KB
testcase_34 AC 260 ms
15,000 KB
testcase_35 AC 261 ms
14,876 KB
testcase_36 AC 256 ms
14,824 KB
testcase_37 AC 265 ms
15,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/

#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define pb push_back
#define ff first
#define ss second
#define isz(x) (int)x.size()
using namespace std;

const int mxN = 2e5 + 5;
const int mod = 1e9 + 7;
const i64 oo = 1e18;

void solve() {
    int n, m; i64 w;
    cin >> n >> m >> w;
    vector<int> a(n), b(m), c(m);
    for (auto &val : a) cin >> val;
    for (auto &val : b) cin >> val;
    for (auto &val : c) cin >> val;

    sort(rall(a));
    vector<i64> pfx(n + 1);
    for (int i = 0; i < n; ++i) pfx[i + 1] = pfx[i] + a[i];

    i64 res = 0;
    for (int i = 0; i < (1 << m); ++i) {
        i64 cw = w, sum = 0;
        for (int j = 0; j < m; ++j) if (i >> j & 1) {
            cw -= b[j];
            sum += c[j];
        }
        if (cw < 0) continue;
        cw = min<i64>(cw, n);
        sum += pfx[cw];
        res = max(res, sum);
    }
    cout << res << endl;
}

signed main() {

#ifndef CDuongg
    if(fopen(taskname".inp", "r"))
        assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout));
#else
    freopen("bai3.inp", "r", stdin);
    freopen("bai3.out", "w", stdout);
    auto start = chrono::high_resolution_clock::now();
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1; //cin >> t;
    while(t--) solve();

#ifdef CDuongg
   auto end = chrono::high_resolution_clock::now();
   cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '=';
   cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
   cout << "Check array size pls sir" << endl;
#endif

}
0