Language: C++

#include<bits/stdc++.h>
#define ll long long int
#define vll vector<pair<ll, ll> >
#define vl vector<ll>
#define vi vector<int>
#define vii vector<pair<int, int> >
const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
using namespace std;

ll power_mod(ll x, ll y, ll p)
{
	ll ans = 1;
	x = x%p;
	if(x==0)
	return p;

	while(y>0)
	{
		if(y&1)
		{
			ans = (ans*x)%p;
		}
		y = y>>1;
		x = (x*x)%p;
	}
	return ans;
} 
int knapSack(ll W, ll wt[], ll val[], ll n) 
{ 
  
    // Base Case 
    if (n == 0 || W == 0) 
        return 0; 
  
    // If weight of the nth item is more 
    // than Knapsack capacity W, then 
    // this item cannot be included 
    // in the optimal solution 
    if (wt[n - 1] > W) 
        return knapSack(W, wt, val, n - 1); 
  
    // Return the maximum of two cases: 
    // (1) nth item included 
    // (2) not included 
    else
        return max( 
            val[n - 1] + knapSack(W - wt[n - 1],  
                                    wt, val, n - 1), 
            knapSack(W, wt, val, n - 1)); 
} 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int t;
	ll n,w,i,j,k;
	cin>>n>>w;
	ll val[n], wt[n];
	for(i=0;i<n;i++)
	{
	    cin>>wt[i]>>val[i];
	}
	cout<<knapSack(w, wt, val, n);
	return 0;
}


Compiler output:
a.cc: In function 'int knapSack(long long int, long long int*, long long int*, long long int)':
a.cc:47:19: error: no matching function for call to 'max(long long int, int)'
   47 |         return max(
      |                ~~~^
   48 |             val[n - 1] + knapSack(W - wt[n - 1],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   49 |                                     wt, val, n - 1),
      |                                     ~~~~~~~~~~~~~~~~
   50 |             knapSack(W, wt, val, n - 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:47:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   47 |         return max(
      |                ~~~^
   48 |             val[n - 1] + knapSack(W - wt[n - 1],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   49 |                                     wt, val, n - 1),
      |                                     ~~~~~~~~~~~~~~~~
   50 |             knapSack(W, wt, val, n - 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:47:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   47 |         return max(
      |                ~~~^
   48 |             val[n - 1] + knapSack(W - wt[n - 1],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   49 |                                     wt, val, n - 1),
      |                                     ~~~~~~~~~~~~~~~~
   50 |             knapSack(W, wt, val, n - 1));
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~