結果
問題 |
No.617 Nafmo、買い出しに行く
|
ユーザー |
![]() |
提出日時 | 2020-01-16 14:28:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 481 bytes |
コンパイル時間 | 660 ms |
コンパイル使用メモリ | 70,036 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 18:21:45 |
合計ジャッジ時間 | 2,260 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <iostream> #include <vector> int N; long K; std::vector<long> v; int main() { std::cin >> N >> K; v.resize(N); for (int i = 0; i < N; ++i) std::cin >> v[i]; int weight = 0; for (int bit = 0; bit < (1 << N); ++bit) { int tmp_weight = 0; for (int i = 0; i < N; ++i) if (bit & (1 << i)) tmp_weight += v[i]; if (tmp_weight <= K) weight = std::max(weight, tmp_weight); } std::cout << weight << std::endl; return 0; }