Language: C++

#include <iostream>
using namespace std;
int main(){
????????int N;
????????int W;
????????cin>>N>>W;
????????int w[N];
????????int v[N];
????????for(int i=0;i<N;i++)
????????????????cin>>v[i]>>w[i];
????????int DP[N+1][W+1];
????????for(int j=0;j<=W;j++)
????????????????DP[0][j]=0;
????????for(int i=1;i<=N;i++)
????????????????for(int j=0;j<=W;j++)
????????????????????????if(j<w[i-1])
????????????????????????????????DP[i][j]=DP[i-1][j];
????????????????????????else{
????????????????????????????????if(DP[i-1][j]>DP[i-1][j-w[i-1]]+v[i-1])
????????????????????????????????????????DP[i][j]=DP[i-1][j];
????????????????????????????????else
????????????????????????????????????????DP[i][j]=DP[i-1][j-w[i-1]]+v[i-1];
????????????????????????}
????????????????????????cout<<DP[N][W]<<endl;
????????????????return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:1: error: expected primary-expression before '?' token
    4 | ????????int N;
      | ^
a.cc:4:2: error: expected primary-expression before '?' token
    4 | ????????int N;
      |  ^
a.cc:4:3: error: expected primary-expression before '?' token
    4 | ????????int N;
      |   ^
a.cc:4:4: error: expected primary-expression before '?' token
    4 | ????????int N;
      |    ^
a.cc:4:5: error: expected primary-expression before '?' token
    4 | ????????int N;
      |     ^
a.cc:4:6: error: expected primary-expression before '?' token
    4 | ????????int N;
      |      ^
a.cc:4:7: error: expected primary-expression before '?' token
    4 | ????????int N;
      |       ^
a.cc:4:8: error: expected primary-expression before '?' token
    4 | ????????int N;
      |        ^
a.cc:4:9: error: expected primary-expression before 'int'
    4 | ????????int N;
      |         ^~~
a.cc:4:9: error: expected ':' before 'int'
    4 | ????????int N;
      |         ^~~
      |         :
a.cc:4:9: error: expected primary-expression before 'int'
    4 | ????????int N;
      |         ^~~
a.cc:4:9: error: expected ':' before 'int'
    4 | ????????int N;
      |         ^~~
      |         :
a.cc:4:9: error: expected primary-expression before 'int'
    4 | ????????int N;
      |         ^~~
a.cc:4:9: error: expected ':' before 'int'
    4 | ????????int N;
      |         ^~~
      |         :
a.cc:4:9: error: expected primary-expression before 'int'
    4 | ????????int N;
      |         ^~~
a.cc:4:9: error: expected ':' before 'int'
    4 | ????????int N;
      |         ^~~
      |         :
a.cc:4:9: error: expected primary-expression before 'int'
    4 | ????????int N;
      |         ^~~
a.cc:4:9: error: expected ':' before 'int'
    4 | ????????int N;
      |         ^~~
      |         :
a.cc:4:9: error: expected primary-expression before 'int'
    4 | ????????int N;
      |         ^~~
a.cc:4:9: error: expected ':' before 'int'
    4 | ????????int N;
      |         ^~~
      |         :
a.cc:4:9: error: expected primary-expression before 'int'
    4 | ????????int N;
      |         ^~~
a.cc:4:9: error: expected ':' before 'int'
    4 | ????????int N;
      |         ^~~
      |         :
a.cc:4:9: error: expected primary-expression before 'int'
    4 | ????????int N;
      |         ^~~
a.cc:4:9: error: expected ':' before 'int'
    4 | ????????int N;
      |         ^~~
      |         :
a.cc:4:9: error: expected primary-expression before 'int'
    4 | ????????int N;
      |         ^~~
a.cc:5:1: error: expected primary-expression before '?' token
    5 | ????????int W;
      | ^
a.cc:5:2: error: expected primary-expression before '?' token
    5 | ????????int W;
      |  ^
a.cc:5:3: error: expected primary-expression before '?' token
    5 | ????????int W;
      |   ^
a.cc:5:4: error: expected primary-expression before '?' token
    5 | ????????int W;
      |    ^
a.cc:5:5: error: expected primary-expression before '?' token
    5 | ????????int W;
      |     ^
a.cc:5:6: error: expected primary-expression before '?' token
    5 | ????????int W;
      |      ^
a.cc:5:7: error: expected primary-expression before '?' token
    5 | ????????int W;
      |       ^
a.cc:5:8: error: expected primary-expression before '?' token
    5 | ????????int W;
      |        ^
a.cc:5:9: error: expected primary-expression before 'int'
    5 | ????????int W;
      |         ^~~
a.cc:5:9: error: expected ':' before 'int'
    5 | ????????int W;
      |         ^~~
      |         :
a.cc:5:9: error: expected primary-expression before 'int'
    5 | ????????int W;
      |         ^~~
a.cc:5:9: error: expected ':' before 'int'
    5 | ????????int W;
      |         ^~~
      |         :
a.cc:5:9: error: expected primary-expression before 'int'
    5 | ????????int W;
      |         ^~~
a.cc:5:9: error: expected ':' before 'int'
    5 | ????????int W;
      |         ^~~
      |         :
a.cc:5:9: error: expected primary-expression before 'int'
    5 | ????????int W;
      |         ^~~
a.cc:5:9: error: expected ':' before 'int'
    5 | ????????int W;
      |         ^~~
      |         :
a.cc:5:9: error: expected primary-expression before 'int'
    5 | ????????int W;
      |         ^~~
a.cc:5:9: error: expected ':' before 'int'
    5 | ????????int W;
      |         ^~~
      |         :
a.cc:5:9: error: expected primary-expression before 'int'
    5 | ????????int W;
      |         ^~~
a.cc:5:9: error: expected ':' before 'int'
    5 | ????????int W;
      |         ^~~
      |         :
a.cc:5:9: error: expected primary-expression before 'int'
    5 | ????????int W;
      |         ^~~
a.cc:5:9: error: expected ':' before 'int'
    5 | ????????int W;
      |         ^~~
      |         :
a.cc:5:9: error: expected primary-expression before 'int'
    5 | ????????int W;
      |         ^~~
a.cc:5:9: error: expected ':' before 'int'
    5 | ????????int W;
      |         ^~~
      |         :
a.cc:5:9: error: expected primary-expression before 'int'
    5 | ????????int W;
      |         ^~~
a.cc:6:1: error: expected primary-expression before '?' token
    6 | ????????cin>>N>>W;
      | ^
a.cc:6:2: error: expected primary-expression before '?' token
    6 | ????????cin>>N>>W;
      |  ^
a.cc:6:3: error: expected primary-expression before '?' token
    6 | ????????cin>>N>>W;
      |   ^
a.cc:6:4: error: expected primary-expression before '?' token
    6 | ????????cin>>N>>W;
      |    ^
a.cc:6:5: error: expected primary-expression before '?' token
    6 | ????????cin>>N>>W;
      |     ^
a.cc:6:6: error: expected primary-expression before '?' token
    6 | ????????cin>>N>>W;
      |      ^
a.cc:6:7: error: expected primary-expression before '?' token
    6 | ????????cin>>N>>W;
      |       ^
a.cc:6:8: error: expected primary-expression before '?' token
    6 | ????????cin>>N>>W;
      |        ^
a.cc:6:14: error: 'N' was not declared in this scope
    6 | ????????cin>>N>>W;
      |              ^
a.cc:6:17: error: 'W' was not declared in this scope
    6 | ????????cin>>N>>W;
      |                 ^
a.cc:6:18: error: expected ':' before ';' token
    6 | ????????cin>>N>>W;
      |                  ^
      |                  :
a.cc:6:18: error: expected primary-expression before ';' token
a.cc:6:18: error: expected ':' before ';' token
    6 | ????????cin>>N>>W;
      |                  ^
      |                  :
a.cc:6:18: error: expected primary-expression before ';' token
a.cc:6:18: error: expected ':' before ';' token
    6 | ????????cin>>N>>W;
      |                  ^
      |                  :
a.cc:6:18: error: expected primary-expression before ';' token
a.cc:6:18: error: expected ':' before ';' token
    6 | ????????cin>>N>>W;
      |                  ^
      |                  :
a.cc:6:18: error: expected primary-expression before ';' token
a.cc:6:18: error: expected ':' before ';' token
    6 | ????????cin>>N>>W;
      |                  ^
      |                  :
a.cc:6:18: error: expected primary-expression before ';' token
a.cc:6:18: error: expected ':' before ';' token
    6 | ????????cin>>N>>W;
      |                  ^
      |                  :
a.cc:6:18: error: expected primary-expression before ';' token
a.cc:6:18: error: expected ':' before ';' token
    6 | ????????cin>>N>>W;
      |                  ^
      |                  :
a.cc:6:18: error: expected primary-expression before ';' token
a.cc:6:18: error: expected ':' before ';' token
    6 | ????????cin>>N>>W;
      |                  ^
      |                  :
a.cc:6:18: error: expected primary-expression before ';' token
a.cc:7:1: error: expected primary-expression before '?' token
    7 | ????????int w[N];
      | ^
a.cc:7:2: error: expected primary-expression before '?' token
    7 | ????????int w[N];
      |  ^
a.cc:7:3: error: expected primary-expression before '?' token
    7 | ????????int w[N];
      |   ^
a.cc:7:4: error: expected primary-expression before '?' token
    7 | ????????int w[N];
      |    ^
a.cc:7:5: error: expected primary-expression before '?' token
    7 | ????????int w[N];
      |     ^
a.cc:7:6: error: expected primary-expression before '?' token
    7 | ????????int w[N];
      |      ^
a.cc:7:7: error: expected primary-expression before '?' token
    7 | ????????int w[N];
      |       ^
a.cc:7:8: error: expected primary-expression before '?' token
    7 | ????????int w[N];
      |        ^
a.cc:7:9: error: expected primary-expression before 'int'
    7 | ????????int w[N];
      |         ^~~
a.cc:7:9: error: expected ':' before 'int'
    7 | ????????int w[N];
      |         ^~~
      |         :
a.cc:7:9: error: expected primary-expression before 'int'
    7 | ????????int w[N];
      |         ^~~
a.cc:7:9: error: expected ':' before 'int'
    7 | ????????int w[N];
      |         ^~~
      |         :
a.cc:7:9: error: expected primary-expression before 'int'
    7 | ????????int w[N];
      |         ^~~
a.cc:7:9: error: expected ':' before 'int'
    7 | ????????int w[N];
      |         ^~~
      |         :
a.cc:7:9: error: expected primary-expression before 'int'
    7 | ????????int w[N];
      |         ^~~
a.cc:7:9: error: expected ':' before 'int'
    7 | ????????int w[N];
      |         ^~~
      |         :
a.cc:7:9: error: expected primary-expression before 'int'
    7 | ????????int w[N];
      |         ^~~
a.cc:7:9: error: expected ':' before 'int'
    7 | ????????int w[N];
      |         ^~~
      |         :
a.cc:7:9: error: expected primary-expression before 'int'
    7 | ????????int w[N];
      |         ^~~
a.cc:7:9: error: expected ':' before 'int'
    7 | ????????int w[N];
      |         ^~~
      |         :
a.cc:7:9: error: expected primary-expression before 'int'
    7 | ????????int w[N];
      |         ^~~
a.cc:7:9: error: expected ':' before 'int'
    7 | ????????int w[N];
      |         ^~~
      |         :
a.cc:7:9: error: expected primary-expression before 'int'
    7 | ????????int w[N];
      |         ^~~
a.cc:7:9: error: expected ':' before 'int'
    7 | ????????int w[N];
      |         ^~~
      |         :
a.cc:7:9: error: expected primary-expression before 'int'
    7 | ????????int w[N];