結果

問題 No.617 Nafmo、買い出しに行く
ユーザー sggkshiosggkshio
提出日時 2018-07-09 08:09:55
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 891 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 82,060 KB
実行使用メモリ 42,368 KB
最終ジャッジ日時 2023-09-22 08:28:37
合計ジャッジ時間 8,770 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>

bool f[22][2000005] = {};
int main() {
	long long int n, k, a[25] = {};
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];

	int ans = 0;
	f[0][0] = 1;
	for (int i = 0; i <= k; i++) {
		if (!f[i])continue;
		ans = i;
		if (i == k)break;
		for (int j = 0; j < n; j++) {
			for (int j = 0; j <= k; j++) {
				if (!f[i][j])continue;
				f[i + 1][k] = 1;
				f[i + 1][k + a[i]] = 1;
			}
		}
	}
	for (int i = k; i >= 0; i--) {
		if (f[n][i]) {
			cout << ans << endl;
			return 0;
		}
	}

	return 0;
}
0