public int maxValue(int maxWeight, Bags[] bags) {
		int[][] bestValues = new int[bags.length + 1][maxWeight + 1];
		for (int j = 0; j <= maxWeight; j++) {
			for (int i = 0; i <= bags.length; i++) {
				if (i == 0 || j == 0) {
					bestValues[i][j] = 0;
				} else {
					if (bags[i - 1].getWeight() > j) {
						bestValues[i][j] = bestValues[i - 1][j];
					} else {
						bestValues[i][j] = Math.max(bestValues[i - 1][j],
								bestValues[i - 1][j - bags[i - 1].getWeight()]
										+ bags[i - 1].getValue());
					}
				}
			}
		}
		// Show solution
		int tempWeight = maxWeight;
		for (int i = bags.length - 1; i >= 1; i--) {
			if (bestValues[i][tempWeight] > bestValues[i - 1][tempWeight]) {
				System.out.print(bags[i - 1]); // bags[i-1]
												// 表示第
												// i
												// 个背包
				tempWeight -= bags[i - 1].getWeight();
			}
			if (tempWeight == 0) {
				break;
			}
		}
		System.out.println();
		return bestValues[bags.length - 1][maxWeight];
	}