結果
問題 | No.2730 Two Types Luggage |
ユーザー |
|
提出日時 | 2024-04-19 21:23:32 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 276 ms / 2,000 ms |
コード長 | 775 bytes |
コンパイル時間 | 3,427 ms |
コンパイル使用メモリ | 253,324 KB |
実行使用メモリ | 19,444 KB |
最終ジャッジ日時 | 2024-10-11 13:49:22 |
合計ジャッジ時間 | 10,003 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#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;}