hdu 1789. Greedy algorithm. Min-Heap