結果

問題 No.617 Nafmo、買い出しに行く
ユーザー EspeceEspece
提出日時 2017-12-22 18:11:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 814 bytes
コンパイル時間 1,047 ms
コンパイル使用メモリ 76,288 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-22 21:20:17
合計ジャッジ時間 3,796 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 1 ms
4,380 KB
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstring>
#include<complex>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<numeric>
using namespace std;

#define REP(i, j) for (int i = 0; i < (int)j; ++i)
#define FOR(i, j, k) for (int i = (int)j; i < (int)k; ++i)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v) reverse(v.begin(), v.end())
typedef complex<double> P;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	VI v;
	REP(i,n) {
		int a;
		cin >> a;
		v.push_back(a);
	}

	int ans = 0;
	REP(i,1<<n) {
		int sum = 0;
		REP(j,n) {
			if (i&(1<<j)) sum += v[i];
		}
		if (sum <= k) ans = max(ans, sum);
	}

	cout << ans << endl;

	return 0;
}
0