結果
| 問題 | No.617 Nafmo、買い出しに行く |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-15 21:06:08 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 65 ms / 2,000 ms |
| + 934µs | |
| コード長 | 445 bytes |
| 記録 | |
| コンパイル時間 | 266 ms |
| コンパイル使用メモリ | 74,512 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-09-20 02:25:24 |
| 合計ジャッジ時間 | 2,567 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include<iostream>
using namespace std;
int N, K;
int a[22];
int main() {
cin >> N >> K;
for(int i=0; i<N; i++) {
cin >> a[i];
}
int ans = 0;
for(int num=0; num<(1<<N); num++) {
int wei = 0;
for(int b=0; b<N; b++) {
if(num&(1<<b)) {
wei += a[b];
}
}
if(wei <= K) {
ans = max(ans, wei);
}
}
cout << ans << endl;
}