結果
問題 |
No.617 Nafmo、買い出しに行く
|
ユーザー |
![]() |
提出日時 | 2022-07-12 22:17:13 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 74 ms / 2,000 ms |
コード長 | 340 bytes |
コンパイル時間 | 3,436 ms |
コンパイル使用メモリ | 247,972 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 20:20:57 |
合計ジャッジ時間 | 4,412 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ int N,K; cin>>N>>K; vector<int> S(N); int ans = 0; for(int i=0;i<N;i++) cin>>S[i]; for(int i=0;i<(1<<N);i++){ int now = 0; for(int j=0;j<N;j++)if((1<<j)&(i)) now+=S[j]; if(now <= K) ans = max(ans,now); } cout<<ans<<endl; }