Language: C++

#include<bits/stdc++.h>
using namespace std;
 
long long baseW;
long long N, W;
vector<long long> val[4];
 
int main(){
	cin >> N >> W;
	for(long long i = 0; i < N; i++){
		long long tmpw, tmpv;
		cin >> tmpw >> tmpv;
		if(i == 0){
			baseW = tmpw;
		}
		val[tmpw - baseW].push_back(tmpv);
	}
	for(int i = 0; i < 4; i++){
		sort(val[i].begin(), val[i].end(), greater<long long>());
		val[i].insert(val[i].begin(), 0);
		for(int j = 0; j < val[i].size() - 1; j++){
			val[i][j+1] += val[i][j];
		}
	}
 
	long long ans = 0;
	for(long long i = 0; i < val[0].size(); i++){
		for(long long j = 0; j < val[1].size(); j++){
			for(long long k = 0; k < val[2].size(); k++){
				long long curw;
				curw = i * baseW + j * (baseW + 1) + k * (baseW + 2);
				if(curw > W){
					continue;
				}else{
					long long l = (W - curw)/(baseW + 3);
					ans = max(ans, val[0][i] + val[1][j] + val[2][k] + val[3][min(l, val[3].size() - 1)]);
				}
			}
		}
	}

	/*
	for(long long i = 0; i < val[0].size(); i++){
		for(long long j = 0; j < val[1].size(); j++){
			for(long long k = 0; k < val[2].size(); k++){
				for(long long l = 0; l < val[3].size(); l++){
					long long curw;
					if(i * baseW + j * (baseW + 1) + k * (baseW + 2) + l * (baseW + 3) > W){
						continue;
					}else{
						ans = max(ans, val[0][i] + val[1][j] + val[2][k] + val[3][l]);
					}
				}
			}
		}
	}
	*/


	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:102: error: no matching function for call to 'min(long long int&, std::vector<long long int>::size_type)'
   36 |                                         ans = max(ans, val[0][i] + val[1][j] + val[2][k] + val[3][min(l, val[3].size() - 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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:36:102: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'})
   36 |                                         ans = max(ans, val[0][i] + val[1][j] + val[2][k] + val[3][min(l, val[3].size() - 1)]);
      |                                                                                                   ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:36:102: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |                                         ans = max(ans, val[0][i] + val[1][j] + val[2][k] + val[3][min(l, val[3].size() - 1)]);
      |                                                                                                   ~~~^~~~~~~~~~~~~~~~~~~~~~