Due to the celebration of the new 2003 year, chief accountant of Mocrosoft decided to pay a New Year Bonus Grant of 1000 dollars to some programmers. However being extremely concerned of the company wealth she would like to designate the least possible amount of money for these grants. On the other hand she didn’t want to be accused of being too greedy or of giving preferences to some programmers. To do this, she developed the following scheme of grants appointment:
• Each programmer may either assign a grant to one of his subordinates or have a grant assigned to him by his chief or none of the above.
• No programmer can simultaneously receive a grant and assign a grant to one of his subordinates.
• No programmer can assign a grant to more than one of his subordinates
The scheme seemed to be designed perfectly — nobody would like to assign a grant to anybody since in this case he himself would not receive money. But programmers somehow discovered the plan of chief accountant and decided to make a trick to get the most money possible and share them fairly afterwards. The idea was to make such grant assignments that the total amount of grant money received is maximum possible.
You were selected to write the program which will find the optimal grants appointment.
4 1 1 2
2000 3 4