結果

問題 No.2730 Two Types Luggage
ユーザー snrnsidysnrnsidy
提出日時 2024-04-19 21:30:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 1,083 bytes
コンパイル時間 2,408 ms
コンパイル使用メモリ 201,144 KB
実行使用メモリ 19,052 KB
最終ジャッジ日時 2024-04-19 21:30:58
合計ジャッジ時間 8,436 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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,940 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 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 8 ms
6,940 KB
testcase_11 AC 149 ms
16,416 KB
testcase_12 AC 258 ms
18,892 KB
testcase_13 AC 121 ms
13,756 KB
testcase_14 AC 151 ms
17,648 KB
testcase_15 AC 100 ms
7,564 KB
testcase_16 AC 60 ms
8,880 KB
testcase_17 AC 211 ms
18,104 KB
testcase_18 AC 178 ms
16,936 KB
testcase_19 AC 17 ms
6,940 KB
testcase_20 AC 70 ms
9,576 KB
testcase_21 AC 142 ms
16,064 KB
testcase_22 AC 209 ms
18,664 KB
testcase_23 AC 25 ms
6,944 KB
testcase_24 AC 87 ms
10,780 KB
testcase_25 AC 158 ms
15,928 KB
testcase_26 AC 42 ms
7,000 KB
testcase_27 AC 145 ms
15,172 KB
testcase_28 AC 88 ms
10,092 KB
testcase_29 AC 179 ms
18,028 KB
testcase_30 AC 78 ms
6,944 KB
testcase_31 AC 123 ms
14,544 KB
testcase_32 AC 108 ms
13,184 KB
testcase_33 AC 266 ms
19,020 KB
testcase_34 AC 261 ms
19,004 KB
testcase_35 AC 268 ms
19,052 KB
testcase_36 AC 261 ms
18,992 KB
testcase_37 AC 290 ms
18,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

long long int psum[1000001];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

    long long int n,m,w,t;
    vector <long long int> a,b,c;

    cin >> n >> m >> w;
    for(int i=0;i<n;i++)
    {
        cin >> t;
        a.push_back(t);
    }
    for(int i=0;i<m;i++)
    {
        cin >> t;
        b.push_back(t);
    }
    for(int i=0;i<m;i++)
    {
        cin >> t;
        c.push_back(t);
    }    

    sort(a.rbegin(),a.rend());

    for(int i=1;i<=n;i++)
    {
        psum[i] = psum[i-1] + a[i-1];
    }

    long long int res = 0;

    for(int i=0;i<(1<<m);i++)
    {
        long long int sum = 0;
        long long int val = 0;
        for(int j=0;j<m;j++)
        {
            if((i&(1<<j)))
            {
                sum += b[j];
                val += c[j];
            }
        }
        if(sum <= w)
        {
            long long int idx = w - sum;
            idx = min(idx,(long long int)n);
            res = max(res,val + psum[idx]);
        }
    }

    cout << res << '\n';
    
	return 0;
}
0