結果
| 問題 | No.617 Nafmo、買い出しに行く |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-03 10:23:23 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| コード長 | 512 bytes |
| 記録 | |
| コンパイル時間 | 620 ms |
| コンパイル使用メモリ | 64,128 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-28 08:41:13 |
| 合計ジャッジ時間 | 2,090 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include<iostream>
#include<cassert>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
int N,K,A[21],sum=-1;
int main(){
ios::sync_with_stdio(false);
cin>>N>>K;
REP(i,N){cin>>A[i];assert(0<=A[i]&&A[i]<=100000);}
assert(1<=N&&N<=20);
assert(0<=K&&N<=1000000000);
REP(Bit,1<<N){
int temp=0;
REP(i,N){
if(Bit&(1<<i)){
temp+=A[i];
}
}
if(temp<=K)sum=max(sum,temp);
}
cout<<sum<<endl;
return 0;
}