Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

// ABC060D Simple Knapsack

ll solve(int N, int W, vector<ll> &ws, vector<ll> &vs);

int main() {
    ios::sync_with_stdio(false);
    int N, W;
    vector<ll> ws(100, 0);
    vector<ll> vs(100, 0);

    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> ws[i] >> vs[i];

    cout << solve(N, W, ws, vs) << endl;
    return 0;
}

ll solve(int N, int W, vector<ll> &ws, vector<ll> &vs)
{
    auto min_w = ws[0];
    vector<vector<ll>> vv(4, vector<ll>(0));
    for (int i = 0; i < N; ++i) vv[ws[i] - min_w].push_back(vs[i]);
    for (int i = 0; i < 4; ++i) sort(vv[i].begin(), vv[i].end());
    vector<vector<ll>> cumvs(4, vector<ll>(1, 0));
    int i = 0;
    for (auto vec: vv){
        for (auto v: vec) cumvs[i].push_back(cumvs[i].back() + v);
        ++i;
    }

    int record = 0;
    int cum_w0 = 0;
    for (auto cum_v0: cumvs[0]){
        if (cum_w0 > W) break;
        int cum_w1 = cum_w0;
        cum_w0 += min_w;
        for (auto cum_v1: cumvs[1]){
            if (cum_w1 > W) break;
            int cum_w2 = cum_w1;
            cum_w1 += min_w + 1;
            for (auto cum_v2: cumvs[2]){
                if (cum_w2 > W) break;
                int cum_w3 = cum_w2;
                cum_w2 += min_w + 2;
                for (auto cum_v3: cumvs[3]){
                    if (cum_w3 > W) break;
                    cum_w3 += min_w + 2;
                    record = max(cum_v0 + cum_v1 + cum_v2 + cum_v3, record);
                }
            }
        }
    }
    return record;
}

Compiler output:
a.cc: In function 'll solve(int, int, std::vector<long long int>&, std::vector<long long int>&)':
a.cc:54:33: error: no matching function for call to 'max(long long int, int&)'
   54 |                     record = max(cum_v0 + cum_v1 + cum_v2 + cum_v3, record);
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:54:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   54 |                     record = max(cum_v0 + cum_v1 + cum_v2 + cum_v3, record);
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:54:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   54 |                     record = max(cum_v0 + cum_v1 + cum_v2 + cum_v3, record);
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~