It's Moonfang'sbirthday,and his friends decided to buy him a copy of XianJianQiXiaZhuan V.
Since some offriends have more money available than others, nobody has to pay more than hecan afford. Every contribution will be a multiple of 1 cent,i.e.,nobody can payfractions of a cent.
Everybody writesdown the maxumum amount he is able to contribute. Taking into account thesemaximum amounts from everybody, your task is to share the cost of the presentas fairly as possible. That means, you minimize the largest distance of thecontributions to 1/n-th of the total cost.
In case of atie, minimize the second largest distance, and so on. Since the smallest unitof contribution is 1 cent, there might be more than one possible division ofthe cost. In that case, persons with a higher maximum amount pay more. If thereis still ambiguity, those who come first in the list pay more.
Since you boughtthe present, it is your task to figure out how much everybody has to pay.