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