static int rob(int[] num) {
		int length = num.length;
		if (length == 0) {
			return 0;
		} else if (length == 1) {
			return num[0];
		} else if (length == 2) {
			return num[0] > num[1] ? num[0] : num[1];
		}
		int result = 0;
		int[] max = new int[length];
		max[0] = num[0];
		max[1] = num[1];
		max[2] = num[0] + num[2];
		result = max[1] > max[2] ? max[1] : max[2];
		for (int i = 3; i < length; ++i) {
			max[i] = num[i]
					+ (max[i - 2] > max[i - 3] ? max[i - 2] : max[i - 3]);
			if (max[i] > result) {
				result = max[i];
			}
		}
		return result;
	}