結果
| 問題 | No.617 Nafmo、買い出しに行く |
| コンテスト | |
| ユーザー |
youthfuldays072
|
| 提出日時 | 2018-08-08 08:33:46 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
不安定
|
| 実行時間 | 65 ms / 2,000 ms |
| + 918µs | |
| コード長 | 583 bytes |
| 記録 | |
| コンパイル時間 | 401 ms |
| コンパイル使用メモリ | 94,548 KB |
| 実行使用メモリ | 9,804 KB |
| 最終ジャッジ日時 | 2026-09-01 23:43:29 |
| 合計ジャッジ時間 | 2,540 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<int> a;
a.resize(n);
for (int i = 0; i < n; i++) {
int buf;
cin >> buf;
a[i]=buf;
}
int max = -1;
int sum = 0;
for (int bit = 0; bit < (1 << n); ++bit) {
sum = 0;
for (int i = 0; i < n; ++i) {
if (bit & (1 << i)) {
sum += a[i];
}
}
if (max < sum && sum<=k) {
max = sum;
}
}
cout << max;
}
youthfuldays072