結果
問題 |
No.617 Nafmo、買い出しに行く
|
ユーザー |
|
提出日時 | 2018-01-28 20:38:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 320 bytes |
コンパイル時間 | 1,756 ms |
コンパイル使用メモリ | 167,112 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-29 16:16:47 |
合計ジャッジ時間 | 3,558 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef long long ll; int a[20]; int main(){ int n,k;scanf("%d%d",&n,&k); rep(i,n)scanf("%d",&a[i]); int Max=0; rep(i,1<<n){ int sum=0; rep(j,n){ if(i>>j&1)sum+=a[j]; } if(sum<=k)Max=max(Max,sum); } cout<<Max<<endl; }