Language: C++

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

ll func(vector<ll> val,vector<ll> wt,ll n,ll W)
{
  ll i,j,V=0;
  ll res=-1;
  for(i=0;i<n;i++)
    V+=val[i];
  int dp[n+1][V+1];
  for(i=0;i<=n;i++)
  {
    for(j=0;j<=V;j++)
    {
      if(i==0||j==0)
        dp[i][j]=0;
      else if(val[i-1]<=j)
        dp[i][j]=min(wt[i-1]+dp[i-1][j-val[i-1]],dp[i-1][j]);
      else
        dp[i][j]=dp[i-1][j];
    }
  }
  for(i=0;i<=V;i++)
  {
    if(dp[n][i]<W)
      res=max(res,i);
  }
  return res;
}
int main()
{
  ll n,W,val,wt;
  vector<ll> v,w;
  cin>>n>>W;
  ll i;
  for(i=0;i<n;i++)
  {
    cin>>wt>>val;
    v.push_back(val);
    w.push_back(wt);
  }
  cout<<func(val,wt,n,W)<<"\n";
}


Compiler output:
a.cc: In function 'long long int func(std::vector<long long int>, std::vector<long long int>, long long int, long long int)':
a.cc:19:21: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type, int&)'
   19 |         dp[i][j]=min(wt[i-1]+dp[i-1][j-val[i-1]],dp[i-1][j]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:19:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   19 |         dp[i][j]=min(wt[i-1]+dp[i-1][j-val[i-1]],dp[i-1][j]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:19:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   19 |         dp[i][j]=min(wt[i-1]+dp[i-1][j-val[i-1]],dp[i-1][j]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:43:14: error: could not convert 'val' from 'long long int' to 'std::vector<long long int>'
   43 |   cout<<func(val,wt,n,W)<<"\n";
      |              ^~~
      |              |
      |              long long int