結果

問題 No.2730 Two Types Luggage
ユーザー 👑 hitonanodehitonanode
提出日時 2024-04-19 22:28:01
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 299 ms / 2,000 ms
コード長 1,220 bytes
コンパイル時間 1,403 ms
コンパイル使用メモリ 110,776 KB
実行使用メモリ 18,816 KB
最終ジャッジ日時 2024-04-19 22:28:33
合計ジャッジ時間 7,859 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 6 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 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 7 ms
5,376 KB
testcase_11 AC 155 ms
14,720 KB
testcase_12 AC 270 ms
18,560 KB
testcase_13 AC 123 ms
12,416 KB
testcase_14 AC 152 ms
14,720 KB
testcase_15 AC 111 ms
6,144 KB
testcase_16 AC 56 ms
7,296 KB
testcase_17 AC 193 ms
17,920 KB
testcase_18 AC 185 ms
16,896 KB
testcase_19 AC 16 ms
5,376 KB
testcase_20 AC 71 ms
8,704 KB
testcase_21 AC 142 ms
14,080 KB
testcase_22 AC 207 ms
18,432 KB
testcase_23 AC 24 ms
5,376 KB
testcase_24 AC 85 ms
9,472 KB
testcase_25 AC 154 ms
14,848 KB
testcase_26 AC 44 ms
6,272 KB
testcase_27 AC 148 ms
14,080 KB
testcase_28 AC 79 ms
9,088 KB
testcase_29 AC 183 ms
16,896 KB
testcase_30 AC 99 ms
5,376 KB
testcase_31 AC 121 ms
12,160 KB
testcase_32 AC 106 ms
11,392 KB
testcase_33 AC 285 ms
18,816 KB
testcase_34 AC 288 ms
18,816 KB
testcase_35 AC 299 ms
18,688 KB
testcase_36 AC 293 ms
18,688 KB
testcase_37 AC 284 ms
18,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using lint = long long;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
template <typename T> bool chmax(T &m, const T q) { return m < q ? (m = q, true) : false; }
template <typename T> bool chmin(T &m, const T q) { return m > q ? (m = q, true) : false; }
template <class IStream, class T> IStream &operator>>(IStream &is, std::vector<T> &vec) { for (auto &v : vec) is >> v; return is; }



int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, M;
    lint W;
    cin >> N >> M >> W;
    vector<lint> A(N), B(M), C(M);
    cin >> A >> B >> C;

    sort(A.rbegin(), A.rend());
    vector<lint> acs(N + 1);
    REP(i, N) acs.at(i + 1) = acs.at(i) + A.at(i);

    lint ret = 0;
    REP(S, 1 << M) {
        lint wsum = 0;
        lint vsum = 0;
        REP(i, M) {
            if ((S >> i) & 1) {
                wsum += B.at(i);
                vsum += C.at(i);

            }
        }
        if (wsum <= W) {
            lint w = W - wsum;
            chmin<lint>(w, N);
            chmax(ret, vsum + acs.at(w));
        }
    }
    cout << ret << '\n';
}
0