Language: C++



#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

constexpr int32_t INF = 2'000'000'000;

int32_t N , K;
int32_t a[5000];
constexpr int32_t NUMBER = 400;
int32_t ignore = -1;
#if 1
int32_t dp[NUMBER][NUMBER + 1];
//[i]以降でMIN以上になるようにとったときのMINからのはみ出しの最小
int32_t func(int i, int MIN)
{
	if (MIN <= 0) {
		return { -MIN,{} };
	}
	if (i == N) {
		return { INF,{} };
	}
	if (dp[i][MIN] != INF) {
		return dp[i][MIN];
	}

	auto pata = func(i + 1, MIN);
	if (i == ignore) {
		return dp[i][MIN] = std::move(pata);
	}
	auto patb = func(i + 1, MIN - a[i]);
	if (pata < patb) {
		return dp[i][MIN] = std::move(pata);
	}
	else {
		//patb.second.push_back(i);
		return dp[i][MIN] = std::move(patb);
	}
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N >> K;
	for (size_t i = 0; i < N; i++)for (size_t j = 0; j <= K; j++) {
		dp[i][j].first = INF;
	}

	for (size_t i = 0; i < N; i++)
	{
		in >> a[i];
		if (a[i] >= K) { --N; --i; }
	}
	//std::sort(a , a + N);

	if (std::accumulate(a, a + N, (uint64_t)0) < K) {
		out << N;
		return 0;
	}

	int32_t count = 0;
	for (size_t i = 0; i < N; i++)
	{
		for (size_t k = 0; k <= i; k++)for (size_t j = 0; j <= K; j++) {
			dp[i][j].first = INF;
		}
		ignore = i;
		if (func(0, K - a[i]) < a[i] || func(0, K - a[i]) == INF) {

		}
		else {
			++count;
		}
		//a[i]が入っている可能性
		//一つもない可能性=>絶対必要(OK)
	}
	out << count << endl;

	return 0;
}
#endif
#if 0
std::pair<int32_t, std::vector<int32_t>> dp[NUMBER][NUMBER+1];
//[i]以降でMIN以上になるようにとったときのMINからのはみ出しの最小
std::pair<int32_t, std::vector<int32_t>> func(int i, int MIN)
{
	if (MIN <= 0) {
		return { -MIN,{} };
	}
	if (i == N) {
		return {INF, {}};
	}
	if (dp[i][MIN].first != INF) {
		return dp[i][MIN];
	}

	auto pata = func(i + 1, MIN);
	if (i == ignore) {
		return dp[i][MIN] = std::move(pata);
	}
	auto patb = func(i + 1, MIN - a[i]);
	if (pata.first < patb.first) {
		return dp[i][MIN] = std::move(pata);
	}
	else {
		//patb.second.push_back(i);
		return dp[i][MIN] = std::move(patb);
	}
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N>>K;
	for (size_t i = 0; i < N; i++)for (size_t j = 0; j <= K; j++) {
		dp[i][j].first = INF;
	}

	for (size_t i = 0; i < N; i++)
	{
		in >> a[i];
		if (a[i] >= K) { --N; --i; }
	}
	//std::sort(a , a + N);

	if (std::accumulate(a,a+N,(uint64_t)0) < K) {
		out << N;
		return 0;
	}

	int32_t count = 0;
	for (size_t i = 0; i < N; i++)
	{
		for (size_t k = 0; k <= i; k++)for (size_t j = 0; j <= K; j++) {
			dp[i][j].first = INF;
		}
		ignore = i;
		if (func(0, K - a[i]).first < a[i] || func(0, K - a[i]).first == INF) {
			
		}
		else{
			++count;
		}
		//a[i]が入っている可能性
		//一つもない可能性=>絶対必要(OK)
	}
	out << count << endl;

	return 0;
}
#endif
#endif

Compiler output:
a.cc: In function 'int32_t func(int, int)':
a.cc:38:34: error: cannot convert '<brace-enclosed initializer list>' to 'int32_t' {aka 'int'} in return
   38 |                 return { -MIN,{} };
      |                                  ^
a.cc:41:33: error: cannot convert '<brace-enclosed initializer list>' to 'int32_t' {aka 'int'} in return
   41 |                 return { INF,{} };
      |                                 ^
a.cc: In function 'int main()':
a.cc:69:26: error: request for member 'first' in 'dp[i][j]', which is of non-class type 'int32_t' {aka 'int'}
   69 |                 dp[i][j].first = INF;
      |                          ^~~~~
a.cc:88:34: error: request for member 'first' in 'dp[i][j]', which is of non-class type 'int32_t' {aka 'int'}
   88 |                         dp[i][j].first = INF;
      |                                  ^~~~~