(String[] args)
| 5 | |
| 6 | class GFG { |
| 7 | public static void main (String[] args) { |
| 8 | //code |
| 9 | Scanner scn = new Scanner(System.in); |
| 10 | int t = scn.nextInt(); |
| 11 | while(t-->0){ |
| 12 | int n = scn.nextInt(); |
| 13 | int w = scn.nextInt(); |
| 14 | |
| 15 | int[][] dp = new int[n+1][w+1]; |
| 16 | for(int[] d: dp) |
| 17 | Arrays.fill(d, -1); |
| 18 | int[] values = new int[n]; |
| 19 | int[] weights = new int[n]; |
| 20 | for(int i = 0;i<n;i++){ |
| 21 | values[i] = scn.nextInt(); |
| 22 | } |
| 23 | for(int i = 0;i<n;i++){ |
| 24 | weights[i] = scn.nextInt(); |
| 25 | } |
| 26 | System.out.println(knapSack_01_Rec(weights, values, w,n, dp)); |
| 27 | } |
| 28 | } |
| 29 | public static int knapSack_01_Rec(int[] weight, int[] value, int cap, int n, int[][] dp){ |
| 30 | int N = n; |
| 31 | int Cap = cap; |
nothing calls this directly
no test coverage detected