Microsoft interview question

A form of the knapsack problem, another question on binary trees.