Language: C++

#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep3(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define ll long long

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll dp[101][100001]; //dpテーブル
ll v[100],w[100];
int N,W;


int rec(int i,int j){
   
  if(dp[i][j]>-1){
    return dp[i][j];
  }
  int res;
  if(i==N){
    res= 0;
  }
  else if(j<w[i]){
    res = rec(i+1,j);//入らない時
  }
  else{
    res = max(rec(i+1,j), rec(i+1,j-w[i])+v[i]);//入れると入れないで比較
    }
  return dp[i][j]=res;
  }

int main() {
  
  cin >>N>>W; 
  rep(i,N)
    cin >> w[i] >> v[i];

  for(int i=0;i<101;i++){
    for(int j=0;j<100001;j++){
      dp[i][j]= -1;
    }
  }
  
  
  cout << rec(0,W)<< endl; // 標準出力
}





Compiler output:
a.cc: In function 'int rec(int, int)':
a.cc:35:14: error: no matching function for call to 'max(int, long long int)'
   35 |     res = max(rec(i+1,j), rec(i+1,j-w[i])+v[i]);//入れると入れないで比較
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:2:
/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:35:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   35 |     res = max(rec(i+1,j), rec(i+1,j-w[i])+v[i]);//入れると入れないで比較
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:6:
/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:35:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   35 |     res = max(rec(i+1,j), rec(i+1,j-w[i])+v[i]);//入れると入れないで比較
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~