結果

問題 No.2730 Two Types Luggage
ユーザー butsurizukibutsurizuki
提出日時 2024-04-19 21:23:32
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 299 ms / 2,000 ms
コード長 775 bytes
コンパイル時間 3,724 ms
コンパイル使用メモリ 283,284 KB
実行使用メモリ 19,436 KB
最終ジャッジ日時 2024-04-19 21:23:56
合計ジャッジ時間 10,864 ms
ジャッジサーバーID
(参考情報)
judge5 / 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 6 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 168 ms
17,312 KB
testcase_12 AC 289 ms
19,196 KB
testcase_13 AC 136 ms
16,120 KB
testcase_14 AC 168 ms
17,432 KB
testcase_15 AC 107 ms
6,856 KB
testcase_16 AC 64 ms
9,640 KB
testcase_17 AC 214 ms
19,048 KB
testcase_18 AC 197 ms
18,432 KB
testcase_19 AC 19 ms
5,376 KB
testcase_20 AC 80 ms
10,232 KB
testcase_21 AC 160 ms
17,092 KB
testcase_22 AC 222 ms
19,280 KB
testcase_23 AC 26 ms
5,376 KB
testcase_24 AC 111 ms
10,588 KB
testcase_25 AC 174 ms
17,396 KB
testcase_26 AC 48 ms
7,076 KB
testcase_27 AC 159 ms
16,972 KB
testcase_28 AC 87 ms
10,508 KB
testcase_29 AC 199 ms
18,476 KB
testcase_30 AC 89 ms
5,376 KB
testcase_31 AC 134 ms
16,024 KB
testcase_32 AC 118 ms
11,460 KB
testcase_33 AC 296 ms
19,436 KB
testcase_34 AC 299 ms
19,304 KB
testcase_35 AC 293 ms
19,304 KB
testcase_36 AC 287 ms
19,312 KB
testcase_37 AC 294 ms
19,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n,m,w;
  cin >> n >> m >> w;
  vector<long long> a(n);
  vector<long long> b(m),c(m);

  for(auto &nx : a){cin >> nx;}
  for(auto &nx : b){cin >> nx;}
  for(auto &nx : c){cin >> nx;}

  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());

  vector<long long> s={0};
  for(auto &nx : a){
    s.push_back(s.back()+nx);
  }

  long long res=0;
  for(long long i=0;i<(1ll<<m);i++){
    long long cres=0,cw=0;
    for(long long j=0;j<m;j++){
      if(i&(1ll<<j)){
        cres+=c[j];
        cw+=b[j];
      }
    }
    cw = w - cw;
    if(cw>=0){
      res=max(res,cres+s[min((long long)(s.size()-1),cw)]);
    }
  }
  cout << res << "\n";
  return 0;
}
0