結果

問題 No.2730 Two Types Luggage
ユーザー warner1129warner1129
提出日時 2024-04-19 21:31:50
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 256 ms / 2,000 ms
コード長 2,134 bytes
コンパイル時間 4,277 ms
コンパイル使用メモリ 291,484 KB
実行使用メモリ 18,816 KB
最終ジャッジ日時 2024-04-19 21:32:19
合計ジャッジ時間 11,290 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 9 ms
5,376 KB
testcase_11 AC 177 ms
14,848 KB
testcase_12 AC 247 ms
18,688 KB
testcase_13 AC 140 ms
12,416 KB
testcase_14 AC 175 ms
14,720 KB
testcase_15 AC 60 ms
6,272 KB
testcase_16 AC 65 ms
7,296 KB
testcase_17 AC 228 ms
18,048 KB
testcase_18 AC 208 ms
16,896 KB
testcase_19 AC 19 ms
5,376 KB
testcase_20 AC 78 ms
8,704 KB
testcase_21 AC 158 ms
14,080 KB
testcase_22 AC 238 ms
18,560 KB
testcase_23 AC 23 ms
5,376 KB
testcase_24 AC 101 ms
9,472 KB
testcase_25 AC 181 ms
14,848 KB
testcase_26 AC 49 ms
6,272 KB
testcase_27 AC 170 ms
14,080 KB
testcase_28 AC 91 ms
9,088 KB
testcase_29 AC 213 ms
16,896 KB
testcase_30 AC 36 ms
5,376 KB
testcase_31 AC 133 ms
12,160 KB
testcase_32 AC 121 ms
11,392 KB
testcase_33 AC 250 ms
18,816 KB
testcase_34 AC 256 ms
18,816 KB
testcase_35 AC 239 ms
18,816 KB
testcase_36 AC 239 ms
18,688 KB
testcase_37 AC 248 ms
18,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

template <class F, class S>
ostream &operator<<(ostream &s, const pair<F, S> &v) {
    s << "(" << v.first << ", " << v.second << ")";
    return s;
}
template <ranges::range T,
          class = enable_if_t<!is_convertible_v<T, string_view>>>
istream &operator>>(istream &s, T &&v) {
    for (auto &&x : v) s >> x;
    return s;
}
template <ranges::range T,
          class = enable_if_t<!is_convertible_v<T, string_view>>>
ostream &operator<<(ostream &s, T &&v) {
    for (auto &&x : v) s << x << ' ';
    return s;
}

#ifdef LOCAL
template <class... T> void dbg(T... x) {
    char e{};
    ((cerr << e << x, e = ' '), ...);
}
#define debug(x...) dbg(#x, '=', x, '\n')
#else
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define debug(...) ((void)0)
#endif

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second

template <class T> inline constexpr T inf = numeric_limits<T>::max() / 2;
template <class T> bool chmin(T &a, T b) { return (b < a and (a = b, true)); }
template <class T> bool chmax(T &a, T b) { return (a < b and (a = b, true)); }

using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;

constexpr i64 mod = 998244353;

void solve() {
    int n, m;
    i64 w;
    cin >> n >> m >> w;

    vector<i64> A(n);
    cin >> A;

    vector<i64> B(m), C(m);
    cin >> B;
    cin >> C;

    sort(rall(A));
    A.insert(A.begin(), 0);
    partial_sum(all(A), A.begin());

    i64 ans = 0;
    for (int s = 0; s < (1 << m); s++) {
        i64 c = 0;
        i64 g = 0;
        for (int i = 0; i < m; i++)
            if (s >> i & 1) {
                g += B[i];
                c += C[i];
            }

        if (g <= w) {
            c += A[min<i64>(n, w - g)];
            chmax(ans, c);
        }
    }

    cout << ans << '\n';

}

signed main() {
    cin.tie(0)->sync_with_stdio(false);
    cin.exceptions(cin.failbit);

    int t = 1;
    // cin >> t;

    while (t--) {
        solve();
    }
    
    return 0;
}




0