結果
| 問題 |
No.617 Nafmo、買い出しに行く
|
| コンテスト | |
| ユーザー |
kyo1
|
| 提出日時 | 2020-08-08 06:00:24 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 73 ms / 2,000 ms |
| コード長 | 444 bytes |
| コンパイル時間 | 3,039 ms |
| コンパイル使用メモリ | 192,492 KB |
| 最終ジャッジ日時 | 2025-01-12 18:45:51 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N, K;
cin >> N >> K;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
int res = 0;
for (int bit = 0; bit < (1 << N); bit++) {
int tot = 0;
for (int i = 0; i < N; i++) {
if ((bit >> i) & 1) tot += A[i];
}
if (tot <= K) res = max(res, tot);
}
cout << res << '\n';
return 0;
}
kyo1