結果
問題 | No.617 Nafmo、買い出しに行く |
ユーザー |
![]() |
提出日時 | 2018-07-18 15:10:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 66 ms / 2,000 ms |
コード長 | 525 bytes |
コンパイル時間 | 1,643 ms |
コンパイル使用メモリ | 168,308 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-14 13:47:36 |
合計ジャッジ時間 | 3,222 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include<bits/stdc++.h>using namespace std;using Int = long long;template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}//INSERT ABOVE HEREsigned main(){Int n,k;cin>>n>>k;vector<Int> a(n);for(Int i=0;i<n;i++) cin>>a[i];Int ans=0;for(Int b=0;b<(1<<n);b++){Int res=0;for(Int i=0;i<n;i++)if((b>>i)&1) res+=a[i];if(res<=k) chmax(ans,res);}cout<<ans<<endl;return 0;}