제출 #1219967

#제출 시각아이디문제언어결과실행 시간메모리
1219967brito.joaoKnapsack (NOI18_knapsack)Pypy 3
컴파일 에러
0 ms0 KiB
import java.util.*;

class GfG {

    // Returns the maximum value that
    // can be put in a knapsack of capacity W
    static int knapsackRec(int W, int[] val, int[] wt, int n) {

        // Base Case
        if (n == 0 || W == 0)
            return 0;

        int pick = 0;

        // Pick nth item if it does not exceed the capacity of knapsack
        if (wt[n - 1] <= W)
            pick = val[n - 1] + knapsackRec(W - wt[n - 1], val, wt, n - 1);
        
        // Don't pick the nth item
        int notPick = knapsackRec(W, val, wt, n - 1);
         
        return Math.max(pick, notPick);
    }

    static int knapsack(int W, int[] val, int[] wt) {
        int n = val.length;
        return knapsackRec(W, val, wt, n);
    }

    public static void main(String[] args) {
        int[] val = {1, 2, 3};
        int[] wt = {4, 5, 1};
        int W = 4;

        System.out.println(knapsack(W, val, wt));
    }
}

컴파일 시 표준 출력 (stdout) 메시지

Compiling 'knapsack.py'...
***   File "knapsack.py", line 19
    // Don't pick the nth item
          ^
SyntaxError: end of line (EOL) while scanning string literal


=======