Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(void){
	int n, W, w_0, w_, v_;
	cin >> n >> W;
	vector<int> v[4];
	for(int i = 0; i < 4; ++i){
		v[i].resize(n+10);
	}
	cin >> w_0 >> v[0][0];
	for(int i = 1; i < n; ++i){
		cin >> w_ >> v_;
		v[w_-w_0].push_back(v_);
	}

	for(int i = 0; i < 4; ++i){
		sort(v[i].rbegin(), v[i].rend());
	}
	for(int i = 0; i < 4; ++i){
		for(int j = 1; j < v[i].size(); ++j){
			v[i][j] += v[i][j-1];
		}
	}

	long long value = 0;
	for(int i = 0; i <= v[0].size(); ++i){
		for(int j = 0; j <= v[1].size(); ++j){
			for(int k = 0; k <= v[2].size(); ++k){
				for(int l = 0; l <= v[3].size(); ++l){
					if(w_0*i+(w_0+1)*j+(w_0+2)*k+(w_0+3)*l>W) continue;
					value = max(value, 
						(i==0?0:v[0][i-1]) +
						(j==0?0:v[1][j-1]) +
						(k==0?0:v[2][k-1]) +
						(l==0?0:v[3][l-1]));
				}
			}
		}
	}
	cout << value << endl;




	return 0;

	// vector<int> w(n), v(n), dp[n+1];
	// for(int i = 0; i < n; ++i){
	// 	cin >> w[i] >> v[i];
	// 	dp[i].resize(W+10);
	// }
	// dp[n].resize(W+10);
	// for(int i = 0; i < n; ++i){
	// 	for(int j = 0; j <= W; ++j){
	// 		if(j >= w[i]){
	// 			dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j]);
	// 		}else{
	// 			dp[i+1][j] = dp[i][j];
	// 		}
	// 	}
	// }
	// cout << dp[n][W] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:52: error: no matching function for call to 'max(long long int&, int)'
   32 |                                         value = max(value,
      |                                                 ~~~^~~~~~~
   33 |                                                 (i==0?0:v[0][i-1]) +
      |                                                 ~~~~~~~~~~~~~~~~~~~~
   34 |                                                 (j==0?0:v[1][j-1]) +
      |                                                 ~~~~~~~~~~~~~~~~~~~~
   35 |                                                 (k==0?0:v[2][k-1]) +
      |                                                 ~~~~~~~~~~~~~~~~~~~~
   36 |                                                 (l==0?0:v[3][l-1]));
      |                                                 ~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 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:32:52: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   32 |                                         value = max(value,
      |                                                 ~~~^~~~~~~
   33 |                                                 (i==0?0:v[0][i-1]) +
      |                                                 ~~~~~~~~~~~~~~~~~~~~
   34 |                                                 (j==0?0:v[1][j-1]) +
      |                                                 ~~~~~~~~~~~~~~~~~~~~
   35 |                                                 (k==0?0:v[2][k-1]) +
      |                                                 ~~~~~~~~~~~~~~~~~~~~
   36 |                                                 (l==0?0:v[3][l-1]));
      |                                                 ~~~~~~~~~~~~~~~~~~~
/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:
/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:32:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |                                         value = max(value,
      |                                                 ~~~^~~~~~~
   33 |                                                 (i==0?0:v[0][i-1]) +
      |                                                 ~~~~~~~~~~~~~~~~~~~~
   34 |                                                 (j==0?0:v[1][j-1]) +
      |                                                 ~~~~~~~~~~~~~~~~~~~~
   35 |                                                 (k==0?0:v[2][k-1]) +
      |                                                 ~~~~~~~~~~~~~~~~~~~~
   36 |                                                 (l==0?0:v[3][l-1]));
      |                                                 ~~~~~~~~~~~~~~~~~~~