Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<tuple>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
const ll MOD = 1e9 + 7;
const ll INF = 1e14 + 7;

ll dp[55][105][55][105];


int main() {


	ll n, k;
	cin >> n >> k;
	vector<ll> v(n + 10);
	for (int i = 1; i <= n; i++)
	{
		cin >> v[i];
	}


	for (ll i = 1; i <= n; i++) {

		for (ll j = 0; j <= k; j++)
		{
			for (ll a = 1; a <= n; a++)
			{
				for (ll b = 0; b <= k; b++)
				{
					dp[i][j][a][b] = -INF;
				}
			}
		}
	}
	dp[1][0][1][0] = 0;
	for (ll i = 1; i <= n; i++) {

		for (ll j = 0; j <= k; j++)
		{
			for (ll a = 1; a <= n ; a++)
			{
				for (ll b = 0; b <= k; b++)
				{
					if (dp[i][j][a][b] == -INF) {
						continue;
					}
					if (i + a > n) {
						continue;
					}
					if (j + b >= k) {
						continue;
					}

					dp[i + 1][j + 2][a + 1][b + 2] = max(dp[i + 1][j + 2][a + 1][b + 2], dp[i][j][a][b]);
					dp[i][j][a + 1][b + 2] = max(dp[i][j][a + 1][b + 2], dp[i][j][a][b]);
					dp[i + 1][j + 2][a][b] = max(dp[i + 1][j + 2][a][b], dp[i][j][a][b]);

					dp[i + 1][j + 2][a + 1][b + 1] = max(dp[i + 1][j + 2][a + 1][b + 1], dp[i][j][a][b] + v[n-a+1]);
					dp[i + 1][j + 1][a + 1][b + 2] = max(dp[i + 1][j + 1][a + 1][b + 2], dp[i][j][a][b] + v[i]);
					dp[i + 1][j + 1][a + 1][b + 1] = max(dp[i + 1][j + 1][a + 1][b + 1], dp[i][j][a][b] + v[n - a + 1] + v[i]);


					dp[i + 1][j + 1][a][b] = max(dp[i + 1][j + 1][a][b], dp[i][j][a][b] + v[i]);
					dp[i][j][a + 1][b + 1] = max(dp[i][j][a + 1][b + 1], dp[i][j][a][b] + v[n - a + 1]);

				}
			}
		}
	}

	ll maxi = -INF;

	for (ll i = 1; i <= n; i++) {

		for (ll j = 0; j <= k; j++)
		{
			for (ll a = 1; a <= n; a++)
			{
				for (ll b = 0; b <= k; b++)
				{
					if (i + a > n) {
						continue;
					}
					if (j + b <= k) {
						maxi = max(maxi, dp[i][j][a][b]);

						//cout << maxi << endl;

					}

				}
			}
		}
	}

	cout << max(maxi,0) << endl;
	return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:142:20: error: no matching function for call to 'max(ll&, int)'
  142 |         cout << max(maxi,0) << endl;
      |                 ~~~^~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:142:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  142 |         cout << max(maxi,0) << endl;
      |                 ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:142:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  142 |         cout << max(maxi,0) << endl;
      |                 ~~~^~~~~~~~