結果
問題 | No.617 Nafmo、買い出しに行く |
ユーザー |
![]() |
提出日時 | 2017-12-17 00:03:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 67 ms / 2,000 ms |
コード長 | 526 bytes |
コンパイル時間 | 901 ms |
コンパイル使用メモリ | 76,020 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-14 22:26:49 |
合計ジャッジ時間 | 2,424 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <algorithm>#include <cstdio>#include <cstring>#include <cmath>using namespace std;int main() {int n, k;cin >> n >> k;vector<int> a(n);for (int i = 0; i < n; i++) {cin >> a[i];}int r = 0;for (int j = 0; j < 1 << n; j++) {int t = 0;for (int i = 0; i < n; i++) {if (j >> i & 1) t += a[i];}if (t <= k && r < t) r = t;}cout << r << endl;return 0;}