public static int backPackII(int m, int[] A, int V[]) {
        // write your code here
        int n=A.length;
        int[][]t=new int[n+1][m+1];
        for (int i=1;i<=n;++i) {
            for (int j=1;j<=m;++j) {
                t[i][j]=t[i-1][j];
                if ((j-A[i-1]>=0)&&(t[i-1][j-A[i-1]]+V[i-1]>t[i][j]))
                    t[i][j]=t[i-1][j-A[i-1]]+V[i-1];
            }
        }
        return t[n][m];
    }