Language: C++

#include <bits/stdc++.h>
using namespace std;
long long dp[105][1005];
using ll = long long;
ll int knapsack(ll int w[],ll int v[],ll int V,ll int n,ll int W)
{
	for(int i=0;i<=V;i++) dp[0][i]=INT_MIN;
	for(int j=0;j<=n;j++) dp[j][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=V;j++){
			if(v[i-1]<=j){
				dp[i][j]=max(w[i-1]+dp[i-1][j-v[i-1]],dp[i-1][j]);
			}
			else dp[i][j]=dp[i-1][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=V;j++){
			if(dp[i][j]==W) return j;
		}
	}
	//return dp[1][1];	
}
int main() {
	ll int n,W;
	cin>>n>>W;
	ll int w[n],v[n];
	memset(dp,-1,sizeof dp);
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	ll int V=0;
	for(int i=0;i<n;i++) V+=v[i];
	cout<<knapsack(w,v,V,n,W)<<'\n';
}


Compiler output:
a.cc:5:17: error: two or more data types in declaration of 'w'
    5 | ll int knapsack(ll int w[],ll int v[],ll int V,ll int n,ll int W)
      |                 ^~
a.cc:5:27: error: expected ')' before ',' token
    5 | ll int knapsack(ll int w[],ll int v[],ll int V,ll int n,ll int W)
      |                ~          ^
      |                           )
a.cc:5:1: error: two or more data types in declaration of 'knapsack'
    5 | ll int knapsack(ll int w[],ll int v[],ll int V,ll int n,ll int W)
      | ^~
a.cc:5:31: error: expected initializer before 'int'
    5 | ll int knapsack(ll int w[],ll int v[],ll int V,ll int n,ll int W)
      |                               ^~~
a.cc: In function 'int main()':
a.cc:25:9: error: two or more data types in declaration of 'n'
   25 |         ll int n,W;
      |         ^~
a.cc:25:9: error: two or more data types in declaration of 'W'
a.cc:26:14: error: 'n' was not declared in this scope; did you mean 'yn'?
   26 |         cin>>n>>W;
      |              ^
      |              yn
a.cc:26:17: error: 'W' was not declared in this scope
   26 |         cin>>n>>W;
      |                 ^
a.cc:27:9: error: two or more data types in declaration of 'w'
   27 |         ll int w[n],v[n];
      |         ^~
a.cc:27:9: error: two or more data types in declaration of 'v'
a.cc:30:22: error: 'w' was not declared in this scope
   30 |                 cin>>w[i]>>v[i];
      |                      ^
a.cc:30:28: error: 'v' was not declared in this scope
   30 |                 cin>>w[i]>>v[i];
      |                            ^
a.cc:32:9: error: two or more data types in declaration of 'V'
   32 |         ll int V=0;
      |         ^~
a.cc:33:30: error: 'V' was not declared in this scope
   33 |         for(int i=0;i<n;i++) V+=v[i];
      |                              ^
a.cc:33:33: error: 'v' was not declared in this scope
   33 |         for(int i=0;i<n;i++) V+=v[i];
      |                                 ^
a.cc:34:24: error: 'w' was not declared in this scope
   34 |         cout<<knapsack(w,v,V,n,W)<<'\n';
      |                        ^
a.cc:34:26: error: 'v' was not declared in this scope
   34 |         cout<<knapsack(w,v,V,n,W)<<'\n';
      |                          ^
a.cc:34:28: error: 'V' was not declared in this scope
   34 |         cout<<knapsack(w,v,V,n,W)<<'\n';
      |                            ^
a.cc:34:15: error: 'knapsack' was not declared in this scope
   34 |         cout<<knapsack(w,v,V,n,W)<<'\n';
      |               ^~~~~~~~