Language: C++

//@sushkov.pv

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned short int usi;

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(15);

    int s, n;
    cin >> n >> s;
    vector<ll> w(n);
    vector<ll> c(n);
    for(int i = 0; i < n; ++i)
        cin >> w[i] >> c[i];

    vector<ll> dp(s + 1, -1);
    vector<int> prev(s + 1);
    dp[0] = 0;
    prev[0] = 0;

    for(int i = 0; i < n; ++i)
    {
        vector<int> tmp = dp;
        for(int j = w[i]; j <= s; ++j)
        {
            if(dp[j - w[i]] != -1)
            {
                int nw = dp[j - w[i]] + c[i];
                if(tmp[j] < nw)
                {
                    tmp[j] = nw;
                    prev[j] = i;
                }
            }
        }
        dp = tmp;
    }

    ll mx = 0;
    for(int i = 0; i <= s; ++i)
        mx = max(mx, dp[i]);

    cout << mx;
}
























Compiler output:
a.cc: In function 'int main()':
a.cc:32:27: error: conversion from 'vector<long long int>' to non-scalar type 'vector<int>' requested
   32 |         vector<int> tmp = dp;
      |                           ^~
a.cc:45:14: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   45 |         dp = tmp;
      |              ^~~
In file included from /usr/include/c++/14/vector:72,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:3:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~