1 class Solution { 2 public: 3 /** 4 * @param m: An integer m denotes the size of a backpack 5 * @param A & V: Given n items with size A[i] and value V[i] 6 * @return: The maximum value 7 */ 8 int backPackII(int m, vector A, vector V) { 9 // write your code here10 vector result(m+1, 0);11 for (int i = 0; i < A.size(); i++) {12 for (int j = m; j >= A[i]; j--) {13 result[j] = max(result[j], result[j-A[i]] + V[i]);14 }15 }16 return result[m];17 }18 };