結果
問題 | No.2730 Two Types Luggage |
ユーザー |
|
提出日時 | 2024-04-19 22:11:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 630 ms / 2,000 ms |
コード長 | 754 bytes |
コンパイル時間 | 3,025 ms |
コンパイル使用メモリ | 200,560 KB |
最終ジャッジ日時 | 2025-02-21 04:25:21 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#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;}