結果

問題 No.617 Nafmo、買い出しに行く
ユーザー hogeover30
提出日時 2018-01-17 19:44:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 2,019 ms
コンパイル使用メモリ 194,388 KB
最終ジャッジ日時 2025-01-05 07:36:14
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, k; cin>>n>>k;
    vector<int> a(n);
    for(auto& e: a) cin>>e;

    int res=0;
    for(int i=0; i<(1<<n); ++i) {
        int w=0;
        for(int j=0; j<n; ++j) {
            if (!(i&(1<<j))) continue;
            w+=a[j];
        }
        if (w<=k) res=max(res, w);
    }
    cout<<res<<endl;
}
0