Language: C++

#include<bits/stdc++.h>
int dp(int n,int w,int wt,int v)
{
  int d[n+1][w+1];
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=w;j++)
    {
      if(i==0||j==0)
        d[i][j]=0;
      else if(w[i-1]<=j)
        d[i][j]=max(d[i-1][j],v[i-1]+d[i-1][j-wt[i-1]]);
      else
        d[i][j]=d[i-1][j];
    }
  }
    return d[n][w];
}
int main()
{
  int n,w;
  cin>>n>>w;
  int wt[n],v[n];
  for(int i=0;i<n;i++)
    cin>>wt[i]>>v[i];
  cout<<dp(n,w,wt,v)<<endl;  
  return 0;
}

Compiler output:
a.cc: In function 'int dp(int, int, int, int)':
a.cc:11:16: error: invalid types 'int[int]' for array subscript
   11 |       else if(w[i-1]<=j)
      |                ^
a.cc:12:32: error: invalid types 'int[int]' for array subscript
   12 |         d[i][j]=max(d[i-1][j],v[i-1]+d[i-1][j-wt[i-1]]);
      |                                ^
a.cc:12:49: error: invalid types 'int[int]' for array subscript
   12 |         d[i][j]=max(d[i-1][j],v[i-1]+d[i-1][j-wt[i-1]]);
      |                                                 ^
a.cc:12:17: error: 'max' was not declared in this scope; did you mean 'std::max'?
   12 |         d[i][j]=max(d[i-1][j],v[i-1]+d[i-1][j-wt[i-1]]);
      |                 ^~~
      |                 std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc: In function 'int main()':
a.cc:22:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   22 |   cin>>n>>w;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:26:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   26 |   cout<<dp(n,w,wt,v)<<endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:26:16: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   26 |   cout<<dp(n,w,wt,v)<<endl;
      |                ^~
      |                |
      |                int*
a.cc:2:24: note:   initializing argument 3 of 'int dp(int, int, int, int)'
    2 | int dp(int n,int w,int wt,int v)
      |                    ~~~~^~
a.cc:26:19: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   26 |   cout<<dp(n,w,wt,v)<<endl;
      |                   ^
      |                   |
      |                   int*
a.cc:2:31: note:   initializing argument 4 of 'int dp(int, int, int, int)'
    2 | int dp(int n,int w,int wt,int v)
      |                           ~~~~^
a.cc:26:23: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   26 |   cout<<dp(n,w,wt,v)<<endl;
      |                       ^~~~
      |                       std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~