結果
問題 | No.2730 Two Types Luggage |
ユーザー |
|
提出日時 | 2024-04-20 01:19:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 282 ms / 2,000 ms |
コード長 | 752 bytes |
コンパイル時間 | 2,247 ms |
コンパイル使用メモリ | 200,800 KB |
最終ジャッジ日時 | 2025-02-21 05:58:03 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;constexpr int MOD=998244353;int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int N,M;ll W;cin>>N>>M>>W;vector A(N,0ll);for(ll &i:A)cin>>i;sort(A.begin(),A.end());A.push_back(0);reverse(A.begin(),A.end());for(int i=1;i<=N;i++){A[i]+=A[i-1];}vector V(M,array<ll,2>());for(int i=0;i<M;i++)cin>>V[i][0];for(int i=0;i<M;i++)cin>>V[i][1];ll ans=0;for(int i=0;i<1<<M;i++){ll nowW=0,nowV=0;for(int j=0;j<M;j++){if(i>>j&1){nowW+=V[j][0];nowV+=V[j][1];}}if(nowW<=W){if(W-nowW>N) ans=max(ans,nowV+A[N]);else ans=max(ans,nowV+A[W-nowW]);}}cout<<ans<<'\n';}