![]() | ||||
Online Judge | Problem Set | Authors | Online Contests | User |
---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
Firing
Description You¡¯ve
finally got mad at ¡°the world¡¯s most stupid¡± employees of yours and
decided to do some firings. You¡¯re now simply too mad to give response
to questions like ¡°Don¡¯t you think it is an even more stupid decision
to have signed them?¡±, yet calm enough to consider the potential profit
and loss from firing a good portion of them. While getting rid of an
employee will save your wage and bonus expenditure on him, termination
of a contract before expiration costs you funds for compensation. If
you fire an employee, you also fire all his underlings and the
underlings of his underlings and those underlings¡¯ underlings¡¯
underlings¡ An employee may serve in several departments and his
(direct or indirect) underlings in one department may be his boss in
another department. Is your firing plan ready now? Input The input starts with two integers n (0 < n ¡Ü 5000) and m (0 ¡Ü m ¡Ü 60000) on the same line. Next follows n + m lines. The first n lines of these give the net profit/loss from firing the i-th employee individually bi (|bi| ¡Ü 107, 1 ¡Ü i ¡Ü n). The remaining m lines each contain two integers i and j (1 ¡Ü i, j ¡Ü n) meaning the i-th employee has the j-th employee as his direct underling. Output Output
two integers separated by a single space: the minimum number of
employees to fire to achieve the maximum profit, and the maximum profit. Sample Input Sample Output Hint Source |
[Submit] [Go Back] [Status] [Discuss]
All Copyright Reserved 2003-2005 Ying Fuchen,Xu Pengcheng
Any problem, Please Contact Administrator