I need an algorithm for the following problem:

There's a tree with N fruits each with its own weight w* and height h . I can only reach a fruit if it's no taller than H inches. Also every time I pick a fruit, all the other fruits in the tree rise by exactly U inches. I need to find out the maximum amount (total weight) of fruits I can collect.*