結果

問題 No.2730 Two Types Luggage
ユーザー twooimp2twooimp2
提出日時 2024-04-19 22:11:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 553 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 2,200 ms
コンパイル使用メモリ 201,124 KB
実行使用メモリ 18,976 KB
最終ジャッジ日時 2024-04-19 22:11:45
合計ジャッジ時間 13,163 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 6 ms
6,940 KB
testcase_05 AC 2 ms
6,940 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 15 ms
6,940 KB
testcase_11 AC 354 ms
15,052 KB
testcase_12 AC 553 ms
18,568 KB
testcase_13 AC 281 ms
12,584 KB
testcase_14 AC 352 ms
14,992 KB
testcase_15 AC 166 ms
6,940 KB
testcase_16 AC 132 ms
7,424 KB
testcase_17 AC 449 ms
18,156 KB
testcase_18 AC 424 ms
17,076 KB
testcase_19 AC 37 ms
6,944 KB
testcase_20 AC 160 ms
8,696 KB
testcase_21 AC 336 ms
14,156 KB
testcase_22 AC 469 ms
18,512 KB
testcase_23 AC 46 ms
6,940 KB
testcase_24 AC 198 ms
9,728 KB
testcase_25 AC 353 ms
15,148 KB
testcase_26 AC 97 ms
6,944 KB
testcase_27 AC 332 ms
14,184 KB
testcase_28 AC 183 ms
9,196 KB
testcase_29 AC 416 ms
16,912 KB
testcase_30 AC 111 ms
6,940 KB
testcase_31 AC 275 ms
12,288 KB
testcase_32 AC 249 ms
11,296 KB
testcase_33 AC 544 ms
18,916 KB
testcase_34 AC 539 ms
18,820 KB
testcase_35 AC 549 ms
18,900 KB
testcase_36 AC 543 ms
18,976 KB
testcase_37 AC 552 ms
18,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ll n,m,w;
  cin>>n>>m>>w;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.rbegin(),a.rend());
  vector<ll> sum(n+1);
  sum[0]=0;
  sum[1]=a[0];
  for(ll i=1;i<n;i++){
    sum[i+1]=sum[i]+a[i];
  }
  vector<ll> b(m);
  for(ll i=0;i<m;i++){
    cin>>b[i];
  }
  vector<ll> c(m);
  for(ll i=0;i<m;i++){
    cin>>c[i];
  }
  ll ans=0;
  for(ll s=0;s<(1<<m);s++){
    ll tmpw=0,tmpv=0;
    for(ll i=0;i<m;i++){
      if(s&(1<<i)){
        tmpw+=b[i];
        tmpv+=c[i];
      }
    }
    if(tmpw<=w){
      ll rest=w-tmpw;
      if(rest>=0){
        rest=min(rest,n);
        tmpv+=sum[rest];
      }
      ans=max(ans,tmpv);
    }
  }
  cout<<ans<<endl;
}
0