QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#68061#4585. Greedy KnapsackHuangHanShengCompile Error//C++981022b2022-12-14 12:54:362022-12-14 12:54:37

Details

answer.code:2:15: error: expected ‘:’ before ‘int’
    2 |         public int knapsackProblem(int[] wt,int[] val,int size){
      |               ^~~~
      |               :
answer.code:2:42: error: expected ‘,’ or ‘...’ before ‘wt’
    2 |         public int knapsackProblem(int[] wt,int[] val,int size){
      |                                          ^~
answer.code:27:2: error: expected ‘;’ after class definition
   27 | }
      |  ^
      |  ;
answer.code: In member function ‘int solution::knapsackProblem(int*)’:
answer.code:4:20: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’
    4 |                 int[][] dp = new int[wt.length][size];
      |                    ^
answer.code:4:20: error: structured binding declaration cannot have type ‘int’
    4 |                 int[][] dp = new int[wt.length][size];
      |                    ^~
answer.code:4:20: note: type must be cv-qualified ‘auto’ or reference to cv-qualified ‘auto’
answer.code:4:20: error: empty structured binding declaration
answer.code:4:22: error: expected initializer before ‘[’ token
    4 |                 int[][] dp = new int[wt.length][size];
      |                      ^
answer.code:6:35: error: ‘size’ was not declared in this scope
    6 |                 for(int i = 0;i < size;i++){
      |                                   ^~~~
answer.code:7:25: error: expected identifier before numeric constant
    7 |                     int[0][i] = 0;
      |                         ^
answer.code:7:25: error: expected ‘]’ before numeric constant
answer.code:7:24: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’
    7 |                     int[0][i] = 0;
      |                        ^
answer.code:7:24: error: structured binding declaration cannot have type ‘int’
answer.code:7:24: note: type must be cv-qualified ‘auto’ or reference to cv-qualified ‘auto’
answer.code:7:24: error: empty structured binding declaration
answer.code:7:27: error: expected initializer before ‘[’ token
    7 |                     int[0][i] = 0;
      |                           ^
answer.code:10:35: error: ‘size’ was not declared in this scope
   10 |                 for(int j = 0;j < size;j++){
      |                                   ^~~~
answer.code:11:24: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’
   11 |                     int[j][0] = 0;
      |                        ^
answer.code:11:24: error: structured binding declaration cannot have type ‘int’
   11 |                     int[j][0] = 0;
      |                        ^~~
answer.code:11:24: note: type must be cv-qualified ‘auto’ or reference to cv-qualified ‘auto’
answer.code:11:25: error: redeclaration of ‘auto j’
   11 |                     int[j][0] = 0;
      |                         ^
answer.code:10:25: note: ‘int j’ previously declared here
   10 |                 for(int j = 0;j < size;j++){
      |                         ^
answer.code:11:27: error: expected initializer before ‘[’ token
   11 |                     int[j][0] = 0;
      |                           ^
answer.code:11:27: error: expected ‘;’ before ‘[’ token
answer.code:14:36: error: ‘N’ was not declared in this scope
   14 |                 for(int i = 1;i <= N;i++){
      |                                    ^
answer.code:16:40: error: ‘W’ was not declared in this scope
   16 |                     for(int j = 0;j <= W;j++){
      |                                        ^
answer.code:18:29: error: ‘wt’ was not declared in this scope
   18 |                         if (wt[i] > W) {
      |                             ^~
answer.code:19:29: error: ‘dp’ was not declared in this scope
   19 |                             dp[i][W] = dp[i-1][W];  //???????
      |                             ^~
answer.code:22:29: error: ‘dp’ was not declared in this scope
   22 |                             dp[i][W] = Math.max(dp[i-1][W],dp[i-1][W-wt[i]] + val[i])
      |                             ^~
answer.code:22:40: error: ‘Math’ was not declared in this scope
   22 |                             dp[i][W] = Math.max(dp[i-1][W],dp[i-1][W-wt[i]] + val[i])
      |                                        ^~~~
answer.code:22:79: error: ‘val’ was not declared in this scope
   22 |                             dp[i][W] = Math.max(dp[i-1][W],dp[i-1][W-wt[i]] + val[i])
      |                                                                               ^~~
answer.code:26:9: warning: no return statement in function returning non-void [-Wreturn-type]
   26 |         }
      |         ^